Well it's not popular (even though it ought to be), but Edsger Dijkstra's
A Discipline of Programming is an approachable and informal (by the author's standards) look at solving non-trivial problems in a provably correct way. In fact the entire EWD archive[1] can be arranged into a course pretty readily, although you'll definitely want to skim or skip large chunks of it. Also some of the papers are just acerbic observations on life, which some people like and some don't.
And there's it's big brother Predicate Calculus and Program Semantics by Dijkstra and Scholten that more rigorously formalizes the same approach.
Dafny[2] is one approach out of Microsoft Research that attempts to provide automated tooling around some of those concepts.
All of the above are excellent places to start if you're interested in learning how to write better code with the imperative languages that you're actually going to use professionally.
[1] https://www.cs.utexas.edu/users/EWD/
[2] https://dafny.org/