When the protagonist is a detective, she or he is presumed to have a set of ethics or moral values. These are called "the detective code," or simply "the code," when discussing the genre. The basics of the code are best summarized by Richard Layman in his discussion of what James Wright of the Pinkerton Detective Agency taught Dashiell Hammett (see Hammett section) To summarize, the detective should be anonymous, eschew publicity, be close-mouthed, and secretive. He or she protects good people from bad people, who do not live by the rules; thus, one may break the rules in dealing with them. The detective ignores rules and conventions of behavior, because the client pays for this. Loyalty to the client is very important, but may be superceded by a personal sense of justice or the rule of law. The detective must keep an emotional distance from the people in the case, retain an objective point of view, and consider all pertinent clues. (below right: Allen Pinkerton, founder)
The classic articulations of the detective code are those delivered by Sam Spade at the end of Dashiell Hammett's The Maltese Falcon and by Philip Marlowe in Raymond Chandler's The Big Sleep. But these set-pieces are already variations on the basic credo above. Spade's speech stresses his loyalty to his ex-partner, his profession, his sense of self-preservation, and his refusal to be a romantic "sap."
When a man's partner is killed he's supposed to do something about it. It doesn't make any difference what you thought of him…. Then it happens we were in the detective business. Well, when one of your organization gets killed it's bad business to let the killer get away with it. It's bad all around – bad for that one organization, bad for every detective everywhere…. Since I've also got something on you, I couldn't be sure that you wouldn't decide to shoot a hole in me some day…. I don't even like the idea of thinking that there might be one chance in a hundred that you'd played me for a sucker. (183-84)
This is already a narrower, more cynical version of the code. Not surprisingly, Chandler liberalized Philip Marlowe's code in The Big Sleep, stressing his "insubordination" of authority and his personal thriftiness, instead of a narrow professionalism.
I'm thirty-three years old, went to college once and can still speak English if there's any demand for it. There isn't much in my trade. I worked for Mr. Wilde, the District Attorney, as an investigator once. … I was fired. For insubordination. I test very high on insubordination… (7)
Marlowe charges $25 a day and expenses. For solving General Sternwood's blackmail case, he merits "fifty dollars and a little gasoline" (69), which he volunteers to return when his client complains:
"I'd like to offer you your money back. It may mean nothing to you. It might mean something to me."
"What does it mean to you?"
"It means I refused payment for an unsatisfactory job. That's all." (127-8)
When Vivian Regan supposes that money motivates Marlowe, he mocks her:
"All I have the itch for is money. I am so money greedy that for twenty-five bucks a day and expenses, mostly gasoline and whiskey, I do my thinking myself, what there is of it; I risk my whole future, the hatred of the cops and of Eddie Mars and his pals, I dodge bullets and eat saps and say thank you very much, if you have any trouble, I hope you'll think of me, I'll just leave one of my cards in case anything comes up." (137-38)
Marlowe also defines more clearly than Spade did the detective's relation to the law. When Mona Mars asserts that "as long as people gamble there will be places for them to gamble, Marlowe tells her: "That's just protective thinking. Once outside the law you're all the way outside…. Don't try to sell me on any high-souled racketeers. They don't come in that pattern" (117). But Marlowe doesn't believe in toadying to the police either: "It's against my principles to tell as much as I've told [the police] tonight, without consulting [the client]. As for the cover-up, I've been in the police business myself, you know. They come a dime a dozen in any big city. Cops get very large and emphatic when an outsider tries to hide anything, but they do the same things themselves every other day…." (69-70).
Most versions of the "code" share these common points. The private eye is 1) dedicated to the client, 2) economical, if not thrifty, in his expenses and personal habits, 3) loyal to his profession, 4) cooperative, to some degree, with the police, 4) concerned with self-survival, and 5) unwilling to be duped by anyone. Later detectives, such as Archer, Spenser, and Warshawski, add a considerable amount of empathetic humanism to the first feature above.