Raymond Chandler had some very strong opinions about writing crime fiction. Here are his rules, as published online at open culture.com. (If I've upset anyone's copyright here, I will remove the information on request)
Crime stories -
1) It must be credibly motivated, both as to the original situation and the dénouement.2) It must be technically sound as to the methods of murder and detection.3) It must be realistic in character, setting and atmosphere. It must be about real people in a real world.4) It must have a sound story value apart from the mystery element: i.e., the investigation itself must be an adventure worth reading.5) It must have enough essential simplicity to be explained easily when the time comes.
6) It must baffle a reasonably intelligent reader.7) The solution must seem inevitable once revealed.8) It must not try to do everything at once. If it is a puzzle story operating in a rather cool, reasonable atmosphere, it cannot also be a violent adventure or a passionate romance.9) It must punish the criminal in one way or another, not necessarily by operation of the law…. If the detective fails to resolve the consequences of the crime, the story is an unresolved chord and leaves irritation behind it.10) It must be honest with the reader.