“I may be wrong. But frankly, I doubt it.” That line, or words to that effect, are a common refrain on “Murder, She Wrote.” It takes a certain amount of flinty self-confidence for a character to pull that off without sounding smug. We live in uncertain times. Hollywood is in its flop era. But when all else fails, there’s always Jessica Fletcher.

No matter my mood or what other TV offerings may be available, I find myself returning to “Murder, She Wrote” over and over again, at least once a week, spotting new details in episodes I’ve seen countless times. It is my comfort watch, but it has also been instructive for me as a TV critic. Once you start analyzing the show’s various components, it becomes clear that too many of those elements are missing from more recent case-of-the-week procedurals. These basics were once considered standard, but I suspect that writers are out of practice. For the past decade or so, they’ve focused on the short seasons and serialized format of streaming endeavors. But writing 22 crackerjack stories a year? A lost art, I fear.

“Murder, She Wrote” — which celebrates its 40th anniversary this year — ran for 12 seasons on CBS and wouldn’t have worked half as well with another actor. Angela Lansbury built her career playing all kinds of eccentrics on stage and screen. But with “Murder, She Wrote,” she understood that wasn’t needed. Give us a personable woman with a good head on her shoulders and let compelling writing do the rest.

The premise is simple but wildly effective every time: Mystery novelist Jessica Fletcher goes about her day — whether at home writing or out traveling the world — when someone turns up dead. Suddenly her common sense and all that background research for her books comes in handy. Sometimes she has a personal connection and that’s why she’s compelled to help. Sometimes she’s just aggravated — offended, even — by incompetent police work. Either way, she’s going to get to the bottom of things. She’s dogged and not above a little subterfuge. But she always comports herself with class, no matter how lurid the circumstances.

The show’s writing, though, is just as key as Lansbury’s performance.

Great television “brings you in, keeps you there and lets you go satisfied,” screenwriter Javier Grillo-Marxuach said in an interview recently. He wasn’t talking about “Murder, She Wrote” specifically, but more broadly the kind of dramas like it that were once the bedrock of television, telling a new story each week and then bidding you adieu — letting you go satisfied — until next time.

Somehow that format has deteriorated over the past decade or so. Streaming rode the prestige wave launched by HBO and ongoing storylines, parceled out chapter by chapter, became the default. Suddenly, the skill needed to write stand-alone episodes was less in demand.

There aren’t many shows of this type anymore, but the handful that have premiered in the years since have a sad trombone quality to them. Audiences watch anyway because we are desperate for the pleasures offered by this genre, but these efforts are too often a simulacrum of better shows that came before. It’s not like “Murder, She Wrote” was trying to be anything other than easy viewing, but it was written with real intelligence, complexity and wit.

We never know the character’s age, but Lansbury was in her 60s for most of the show’s run, and Jessica is undaunted by anxieties related to technology. After spending years writing her books on a manual typewriter at her kitchen table, by the early ’90s she buys a desktop computer and the episode uses this premise as the basis for a murder mystery. It’s a creative way to bring her into the computer age. In another episode, a company has contracted with her to write a virtual reality video game. When her best friend, local doctor Seth Hazlitt, scoffs at the idea, she tells him to get with it — the 21st century is around the corner! In another episode, she’s on a small plane, tapping away on a laptop computer. As a character, she wasn’t one for nostalgia. She adapts to change and is engaged with the world around her.

Not long ago, architecture critic Anjulie Rao wrote about the series, which, she said, is really about real estate. “Jessica Fletcher may have been investigating murders, but the show explored the anxieties of modern development.” There are countless episodes about one developer or another looking to horn in and exploit an area. They are always up to no good, whether they’ve set their sights on small-town Maine or tearing down a historic brownstone in New York.

The show also loves to satirize show business, and multiple episodes are set in Hollywood. One is an obvious parody of “Friends.” Another centers on the “Psycho” house at the Universal Studios lot. Another takes place at a film festival in Milan. Her books were always being adapted — and badly, to her chagrin. When a network head pitches her on a weekly series called “The Jessica Fletcher Mystery Hour,” about “the real-life adventures of a crime-busting mystery writer,” Jessica stops her cold with a meta response. “I don’t write gunfights, car chases or bedroom scenes. Who would watch?”

So many of us, it turns out.

The show’s format can plop Jessica down anywhere, allowing for varied locations and scenarios, whether she’s on an archaeological dig in the Southwest, visiting an ice cream company in middle America or traveling in Russia promoting the latest translation of her books. The show is not trapped by its setting but follows a wanderlust that allows it to take on just about any kind of premise and be assured that Jessica would fit in somehow. Would it surprise you that fewer than 60 of the 264 episodes take place in her hometown of Cabot Cove, Maine?

By Season 6, Lansbury was exhausted, so producers came up with a workaround: Stories anchored by someone who isn’t Jessica Fletcher, although they sometimes include intros and outros provided by her, which is why they’re often called the bookend episodes. The skill level here is off the charts: Introduce a brand-new world and a main character who is fully formed from the get-go, then drop them into a murder mystery that’s as compelling as any Jessica might solve.

Audiences didn’t love the idea; after two seasons, Lansbury went back to a full schedule. But watching those bookend episodes now, I’m impressed with how they’re executed. So much storytelling economy is required, and yet they feel rich and lived-in. You need to care about these new protagonists instantly, and you do. Any one of them could have led a full-blown series of their own.

There’s an old joke that Jessica Fletcher is actually the real killer. How else to account for all those murders every time she’s around? But a different thought comes to mind: How is she not profoundly depressed by all this death that follows her everywhere?

Well, she’s not. Because “Murder, She Wrote” is not that kind of show. Jessica is alert and chipper at the start of each episode, as if all the tragedy that came before has been zeroed out. That’s OK. That’s what TV used to promise: Consistency.

And “Murder, She Wrote” is nothing if not consistent.