Good code is its own best documentation
Amit Shekhar
1.2K69

These are nice aspirations, but I must never have encountered code that’s quite this good.

In my experience, most developers are about average, and even above-average coders are working within time constraints that force them to compromise on elegance in order to deliver a working product in time.

I’ve worked on many systems which have grown over several years, modified by several developers — not just the visionary who might have conceived the thing in the first place — and become increasingly baroque: abstractions leak, intent becomes unclear, methods grow too big to be easily tested.
MVC and hexagonal architecture help, but they only mitigate the problem, not remove it entirely.

In non-trivial and mature software systems, the code almost never explains itself well enough, no matter how well it’s written.

It’s sloppy, but it’s how the world is and we have to deal with it.

In light of this, I always try to take a pragmatic view and consider the poor guy who’ll be working on the code in six months’ time, because that guy might even be me.

So I’m all for having block comments to explain what a section of code is trying to achieve and why; some kind of signpost so that a newcomer can quickly pick things up; extra pieces of documentation giving a high-level overview of the system; anything that oils the wheels of development.