WHAT if you were walking down the street one day, pretty pleased with the way your life and career had worked out, when a homeless man, in an accent once reminiscent of your own, called you by your Christian name?

What, furthermore, if it turned out that this homeless bloke was not just another unfortunate casualty of the streets, but turned out to be someone with whom you were extremely close, during your school and university days?

That’s the intriguing set-up in Irvine-born novelist John Niven’s latest novel. He revealed a few months ago that it was inspired by the sight of an old schoolfriend in the gutter: he thought the man was a down-and-out, only to discover that he was, in fact, a BT engineer at work.

In the book, the accostee is Alan Grainger, a well-connected media personality with a drink problem. In his late 40s, he’s a Scots-born London journalist and author, self-satisfied to a fault, his Scottish accent long since smoothed out.

The National:

Married to a beautiful upper-class woman — daughter of a duke, no less — he has been dealt an incredibly kind run of cards by life. He and Katie (a newspaper columnist to boot) have three kids, all of them expensively educated. The accoster is Craig Carmichael. In a previous existence he was in an indie-rock band that briefly threatened to be the next big thing before it all went sour and it ended up as an overnight failure instead. Life has dealt Craig a run of dodgy cards — alcoholism and destitution — and now here he is, on the streets, living rough.

Grainger, charitably, offers to put his old friend up for a while at his spacious house in Buckinghamshire. He’s glad to do it, even though his wife takes some persuading, and despite the fact he recognises that, even now, he still wants to impress the charismatic Carmichael.

The extensive, expensive home is a million miles from the “concrete new town” of Ardgirvan where both men grew up. The Graingers and their three kids live a privileged lifestyle. They have a cleaner — Petra, a Russian, “thin as a credit card” — who swears in heavily Russian-inflected English way (“PIG OF WOMAN!”) at the TV soap on her iPad as she makes her way through the mound of ironing.

Niven is good on the family dynamic, right down to the authentic-sounding exchanges between Katie and Melissa, her sarky, 16-year-old daughter who, when Grainger speedily lapses back into broad Scots in Carmichael’s company, tells him, with typical forthrightness: “You’ve gone full Scottish since Craig’s been here.”

We also get a convincing picture of the relationship between Grainger and Carmichael, and their affable, bloke-ish banter that never goes too deep. He’s good, too, on the habits and vanities of the London media world, and for a while the book reminds you of Michael Frayn’s 1960s Fleet Street classic Towards The End Of The Morning, in which John Dyson, a gentleman journalist on a respectable broadsheet newspaper, copes with the demands of the presses and the demands of his busy domestic life.

We glimpse some of Grainger’s journalistic colleagues, at least some of whom owe their careers to nothing other than nepotism. At length, the real Carmichael quietly emerges, for reasons that gradually become clear. Mayhem ensues, as the saying goes, and Grainger’s world is turned completely upside down – all of this despite more than one act of kindness on his part towards Carmichael. No good deed goes unpunished, as the old proverb has it. (That, and a quote from F Scott Fitzgerald — “Nothing is as obnoxious as other people’s good luck” – tellingly make up the epigraph).

This reversal in fortunes, however, is condensed into the last 75 pages or so. I would like to have seen it spun out for longer. As it is, the way in which a couple of the loose ends are tidied up feels a bit too smooth, too convenient.

Which is a pity, as there is so much to enjoy in Niven’s latest book: the crisp dialogue; the jokes and the observational one-liners, and its examination of male friendship. There’s also a toilet scene that is horribly funny and which could have been written by Tom Sharpe at his most gleefully imaginative. I read that chapter on a busy train and was laughing so much I got some pitying glances from the people seated close by.

No Good Deed by John Niven is published by Heinemann, priced £16.99