Read, read, read the genre.
If you’re going to write detective fiction, you should read detective fiction. Lots of it. Contemporary, classic, historical, true-crime, fantastical crime…every sort of detective fiction there is. You’ll get a feel for what sorts of plot devices you like (and those you’re not that fond of), and get an understanding of what’s out there (and what’s not).
Decide early on if your story will be fact-based or fantastical.
There are so many ways you can go with a detective story. Are you fascinated by true-crime stories? Or do you prefer crimes that are so out there, so fantastical, that they defy belief? Whatever piques your fancy is what you should be writing about. It shows when an author has passion in what they do, so be sure that you are passionate about your story.
Choose a time period that suits you.
There’s a reason why there are so many detectives based either in Victorian times or present-day: readers love them! But there are so many other time periods that have remained relatively unexplored, at least in terms of detective fiction. Find a time and place that excites you, and set your story there.
Make the case challenging yet doable.
Your hero/heroine should be challenged (and sorely so!) but he/she must, in the end, be able to solve the case in a believable sort of way.
Leave some false trails for readers to follow.
Leave one, leave five; heck, leave as many false trails as you want! Keep your readers guessing. People enjoy a puzzle, so give them one.
But be sure to leave some breadcrumbs on the real trail, too.
Scattered amongst the false trails should be clues that point to the actual solution. These should not be too obvious, but neither should they be too obtuse. The idea is that perhaps a few, extraordinarily observant readers will correctly guess at the ending (and get a delightful sense of superiority from doing so!), whilst most readers will get to the big reveal at the end, clap themselves on the forehead, and say, ‘oh wow, I should have figured that out!’ What you don’t want is for readers to wonder how on earth the story went from A to watermelons with no plausible explanation whatsoever.
Love your detective.
If you love your detective, you will enjoy writing about him/her. Which means that you will write more, and you will write better.
Be yourself.
Although you’ve read every book in the genre you can get your hands on, you don’t want to emulate another writer. Be inspired by them, yes, but hold on to your own voice.
Let your imagination fly.
Your imagination is what makes you you. Don’t constrain it.
There are no rules.
The best fiction flies in the face of convention. It is unique. It makes readers feel. It doesn’t follow the rules, it makes its own…and then it doesn’t follow those rules either.