Commonly in detective fiction, the investigator has some source of income other than detective work and some undesirable eccentricities or striking characteristics. He or she frequently has a less able assistant (or foil) who acts as an audience surrogate for the explanation of the mystery at the end of the story.
One of the earliest examples of detective fiction is Voltaire's Zadig (1748), which features a main character who performs feats of analysis. The Norwegian crime novel "Mordet på Maskinbygger Rolfsen" ("The Murder of Engine Maker Rolfsen") by Maurits Hansen was published in 1839.
Das Fräulein von Scuderi, by E.T.A. Hoffmann, in which Mlle de Scudery, a kind of 18th century Miss Marple, establishes the innocence of the police's favorite suspect in the murder of a jeweller, is sometimes cited as the first detective story and a direct influence on Edgar Allan Poe's "The Murders in the Rue Morgue". However, detective fiction is more often considered to have begun in 1841 with the publication of "The Murders in the Rue Morgue" itself, featuring "the first fictional detective, the eccentric and brilliant C. Auguste Dupin". Poe set up a plot formula that's been successful ever since, give or take a few shifting variables." Poe followed with further Auguste Dupin tales: "The Mystery of Marie Roget" in 1843, and "The Purloined Letter" in 1844. Poe referred to his stories as "tales of ratiocination". In stories such as these, the primary concern of the plot is ascertaining truth, and the usual means of obtaining the truth is through a complex and mysterious process combining intuitive logic, astute observation, and perspicacious inference. "Early detective stories tended to follow an investigating protagonist from the first scene to the last, making the unraveling a practical rather than emotional matter."
"The Mystery of Marie Roget" is particularly interesting because it is a barely fictionalized account based on Poe's theory of what happened to the real-life Mary Cecilia Rogers. The style of the analysis, with its attention to forensic detail, makes it a precursor and perhaps inspiration for the stories about the most famous of all fictional detectives, Arthur Conan Doyle's Sherlock Holmes. Indeed, Holmes mentions the Poe story in the first Conan Doyle novel.
Another early example of a whodunit is a sub-plot in the vast novel Bleak House (1853) by Charles Dickens. The conniving lawyer Tulkinghorn is killed in his office late one night, and the crime is investigated by Inspector Bucket of the Metropolitan police force. Numerous characters appeared on the staircase leading to Tulkinghorn's office that night, some of them in disguise, and Inspector Bucket must penetrate these mysteries to identify the murderer.
Dickens's protégé, Wilkie Collins (1824-1889) — sometimes referred to as the "grandfather of English detective fiction" — is credited with the first great mystery novel, The Woman in White. His novel The Moonstone (1868) was described by T. S. Eliot as "the first and greatest of English detective novels" and by Dorothy L. Sayers as "probably the very finest detective story ever written". Although technically preceded by Charles Felix's The Notting Hill Mystery (1865), The Moonstone can claim to have established the genre with several classic features of the twentieth-century detective story:
Some readers have suggested much earlier prototypes for the whodunnit, most notably the Old Testament story of Susanna and the Elders (Daniel 13; in the Protestant Bible this story is found in the apocrypha); "Oedipus Rex", Sophocles' dramatic masterpiece, in which the young Oedipus tries to find out what happened to his murdered father and to his mother; the story of the dog and the horse related in the third chapter of Voltaire's Zadig (1747).
The hero of these novels is typically a traditional judge or similar official based on historical personages such as Judge Bao (Bao Qingtian) or Judge Dee (Di Renjie). Although the historical characters may have lived in an earlier period (such as the Song or Tang dynasty) the novels are often set in the later Ming or Manchu period.
These novels differ from the Western tradition in several points as described by van Gulik:
Van Gulik chose Di Gong An to translate because it was in his view closer to the Western tradition and more likely to appeal to non-Chinese readers.
The four original Queens of Crime were Agatha Christie, Dorothy L. Sayers, Ngaio Marsh and Margery Allingham. Apart from Ngaio Marsh (New Zealand) they were all female British writers; perhaps Josephine Tey could be added.
The most popular writer of the Golden Age whodunnit, and one of the most popular writers of all time, was Agatha Christie, who produced a long series of books featuring her detectives Hercule Poirot and Miss Marple, amongst others, and usually including a complex puzzle for the baffled and misdirected reader to try and unravel. Also popular were the stories featuring Dorothy L. Sayers's Lord Peter Wimsey and S. S. Van Dine's Philo Vance.
The 'puzzle' approach was carried even further into ingenious and seemingly impossible plots by John Dickson Carr - also writing as Carter Dickson - who is regarded as the master of the "locked room mystery" and Cecil Street, who also wrote as John Rhode, whose detective Dr. Priestley specialised in elaborate technical devices, while in the US the whodunnit was adopted and extended by Rex Stout and Ellery Queen, among others. The emphasis on formal "rules" during the Golden Age (as codified in 1929 by Ronald Knox) produced a variety of reactions. Most writers were content to follow the rules slavishly, some flouted some or all of the conventions, and some exploited the conventions with genius to produce new and startling results.
In the late 1930s, Raymond Chandler updated the form with his private detective Philip Marlowe, who brought a more intimate voice to the detective than Hammett's distant, third-person viewpoint. His cadenced dialogue and cryptic narrations were musical, evoking the dark alleys and tough thugs, rich women and powerful men about whom he wrote. Several feature and television movies have been made about the Philip Marlowe character. James Hadley Chase wrote a few novels with private eyes as the main hero, including "Blonde's Requiem" (1945), "Lay Her Among the Lilies" (1950), and "Figure It Out for Yourself" (1950). Heroes of these novels are typical private eyes which are very similar to Philip Marlowe.
Ross Macdonald, pseudonym of Kenneth Millar, updated the form again with his detective Lew Archer, while still writing in what is considered the PI's Golden Age of Detective Fiction, begun by Hammett. Archer, like Hammett's fictional heroes, was a camera eye, with hardly any known past. "Turn Archer sideways, and he disappears," one reviewer wrote. Two of Macdonald's strengths were his use of psychology and his beautiful prose, which was full of imagery. Like other 'hardboiled' writers, Macdonald aimed to give an impression of realism in his work through violence, sex and confrontation; this is illusory, however, and any real private eye undergoing a typical fictional investigation would soon be dead or incapacitated. The movie Harper starring Paul Newman was based on the Lew Archer character.
Michael Collins, pseudonym of Dennis Lynds, is generally considered the author who led the form into the Modern Age. His PI, Dan Fortune, was consistently involved in the same sort of David-and-Goliath stories that Hammett, Chandler, and Macdonald wrote, but he took a sociological bent, exploring the meaning of his characters' places in society and the impact society had on people. Full of commentary and clipped prose, his books were more intimate than his predecessors, dramatizing that crime can happen in one's own living room.
The PI novel was a male-dominated field in which female authors seldom found publication until Marcia Muller, Sara Paretsky, and Sue Grafton were finally published in the late 1970s and early 1980s. Each author's detective was brainy, physical, and could hold her own. Their acceptance, then success, caused publishers to seek out other female authors.
The PI novel today is rich in variety. The strongest characteristic that binds them is that the detective now has a past and a life, while solving cases.
The first amateur railway detective, Thorpe Hazell, was created by Victor Whitechurch and his stories impressed Ellery Queen and Dorothy L. Sayers.
"Cozy mysteries" began in the late 20th century as a reinvention of the Golden Age whodunnit; these novels generally shy away from violence and suspense and frequently feature female amateur detectives. Modern cozy mysteries are frequently, though not necessarily in either case, humorous and thematic (culinary mystery, animal mystery, quilting mystery, etc.)
Another subgenre of detective fiction is the serial killer mystery, which might be thought of as an outcropping of the police procedural. There are early mystery novels in which a police force attempts to contend with the type of criminal known in the 1920s as a homicidal maniac, such as a few of the early novels of Philip Macdonald and Ellery Queen's Cat of Many Tails. However, this sort of story became much more popular after the coining of the phrase "serial killer" in the 1970s and the publication of The Silence of the Lambs in 1988. These stories frequently show the activities of many members of a police force or government agency in their efforts to apprehend a killer who is selecting victims on some obscure basis. They are also often much more violent and suspenseful than other mysteries.
De Andrea has described the quiet little village of St. Mary Mead as having "put on a pageant of human depravity rivaled only by that of Sodom and Gomorrah". Similarly, TV heroine Jessica Fletcher is confronted with bodies wherever she goes, but over the years people who have met violent deaths have also piled up in the streets of Cabot Cove, Maine, the cozy little village where she lives. Generally, therefore, it is much more convincing if a policeman, private eye, forensic expert or similar professional is made the hero or heroine of a series of crime novels.
This implausibility is satirized frequently on the TV show Monk, in which the main character, Adrian Monk, is frequently accused of being a "bad luck charm" and a "murder magnet" as the result of the frequency with which otherwise normal people attempt to pull off elaborate schemes for perfect murders when he is in the vicinity. Likewise Kogoro Mori of Detective Conan got that kind of unflattering reputation. Although Mori is actually a private investigator with his own agency, the police has never been intentionally consulting him and he just keeps stumbling from one crime scene to another.
Also, the role and legitimacy of coincidence has frequently been the topic of heated arguments ever since Ronald A. Knox categorically stated that "no accident must ever help the detective" (Commandment No.6).
One tactic that avoids the issue of technology altogether is the historical detective genre. As global interconnectedness makes legitimate suspense more difficult to achieve, several writers -- including Elizabeth Peters, P. C. Doherty, Steven Saylor, and Lindsey Davis -- have eschewed fabricating convoluted plots in order to manufacture tension, instead opting to set their characters in some former period. Such a strategy forces the protagonist to rely on more inventive means of investigation, lacking as they do the scientific tools available to modern detectives.
According to "Twenty rules for writing detective stories," by Van Dine in 1928: "The detective story is a kind of intellectual game. It is more--it is a sporting event. And for the writing of detective stories there are very definite laws--unwritten, perhaps, but nonetheless binding; and every respectable and self-respecting concocter of literary mysteries lives up to them. Herewith, then, is a sort of credo, based partly on the practice of all the great writers of detective stories, and partly on the promptings of the honest author's inner conscience. Ronald Knox wrote a set of Ten Commandments or Decalogue in 1929, see article on the Golden Age of Detective Fiction.
Notable fictional detectives and their creators include:
Amateur detectives
Police detectives
Forensic specialists
Catholic Church detectives
Government agents