Television and motion picture tie-in books are always a gamble. Sometimes they’re written on the cheap by newcomers (talented or not), and sometimes hard-working pros (like the late, great Stuart M. Kaminsky) make them a delight… or a disappointment (not in Kaminsky’s case, it goes without saying).

I’m happy to report that Heat Wave by “Richard Castle” is not only a superior effort among tie-in books, but one of the most enjoyable mysteries I’ve read this year.

One warning—the paperback version has the smallest print I’ve seen in a novel in years. If you’re over 50, you’ll need your bifocals for this one.

For those unfamiliar with the joke, “Richard Castle” is the hero of an ABC television series, “Castle,” in which he’s portrayed by the charismatic actor Nathan Fillion. Castle is a bestselling author who exerts personal leverage to get permission to follow around a New York detective squad led by Det. Kate Beckett (played by the statuesque Stana Katic). Castle falls in love with Beckett, who is attracted but keeps him at an arm’s length. He makes her the heroine (thinly disguised under the name “Nikki Heat”) of a novel called Heat Wave. That book (we are invited to believe) is the one we are reading here.

First of all, in case you’re wondering, it doesn’t work this way in real life fiction writing. You can’t take private citizens you know, just change their names, and portray them in recognizable form in a novel. Authors have been sued successfully for less.

But overlooking that bit of license, the translation of a fictional situation into a fiction of a fictional situation works very well here. The reader can easily imagine the television characters under their new names, and the dialogue is even better than on the screen (which is saying a lot; it’s a well-written show).

The mystery involves the death of a Manhattan real estate developer, sort of a second-tier Donald Trump, who leaps (or is pushed) from the balcony of his penthouse apartment. As Detective Heat and her team start poking in his affairs, they discover that he was in fact on the verge of bankruptcy. But with nothing left to inherit, and his insurance canceled, who had a motive to kill him?

One nice thing about the book (as about the TV show) is that the writer (“Jameson Rook,” in his double-fictional incarnation) is not a Miss Marple-esque amateur savant who puts the professionals to shame. Rook has a good idea now and then, but he’s usually tagging along, both literally and metaphorically, and when the detectives eventually figure out whodunnit, they keep it from him for a while, just to remind him of his place. Also, when it comes to the action parts, he’s more of a hindrance than a help.

It restores some of the verisimilitude the story lost in the early stages.

Heat Wave is a very enjoyable mystery, way superior to anything I expected.

Mild cautions for language and adult themes.

Lars Walker is the author of several fantasy novels, the latest of which is West Oversea.