An Essential Murder
Detective stories feature at least one murder, which occurs at the beginning of the story. The "how to" of murder -- whether it is by shooting, stabbing, poisoning, asphyxiation, drowning or some other technique -- is for the writer to invent. No murder, however, is perfect. The murder scene works best in a "closed space" such as a country house, a train carriage or a college. It also serves as the site of multiple clues for the detective's discerning eyes. Depending on the plot, more murders can occur throughout the story, but it must begin with one.
A Detective Hero
There wouldn't be a detective story without a detective. After finishing the book, the reader remembers vague basics of the plot, and the detective -- if sketched with care -- stands out. The detective is essentially the hero (or heroine) of a detective story. He or she can be an amateur, such as Sherlock Holmes, or a professional detective from the police department. However, the rules of the genre dictate that the detective be an outsider. He or she should not be related to the suspect or the victims. In addition, he or she should have a keen eye for a details and a passion for logic.
The Usual Suspects
There are multiple suspects who either gain materially from the victim's death or are opposed to the dead person for a reason. Otherwise, the suspects, including the criminal, do not have a believable motive to commit the crime. As the story proceeds, the writer should give clues about the identity of the criminal. An astute reader, therefore, is able to identify the criminal before the writer has exposed him to everyone. The writer can plant false leads to deceive the naive reader, which is part of the fun in writing detective stories. The story can also feature a game of cat and mouse between the detective and the criminal where the latter tries to mislead or even murder the former.
A Logical Solution
Detective stories are usually solved with identification of the criminal. However, there are rules on the methods of solution. The solution must follow from clues that are presented to the reader, and the identity of the criminal must be apparent, at least in retrospect. The solution relies on reasoning and logic. Accidental solutions and solutions with the help of supernatural forces and seances are not allowed. It is also disrespectful to the readers to have the detective be the criminal. At the end of the story, the writer can kill or otherwise remove the criminal from the environment and allow the suspects to resume living in peace.