Writing code that comments itself

My first piece of advice in my guide to comments is that you shouldn’t use comments.

That is, if you choose your variable names and method names well, lay out your code well and your code is doing something trivial ( I mean really trivial, not something that seems trivial now but won’t be in three months time when you’re no longer immersed in the project) then your code might not need comments.

From the machine’s perspective these two pieces of code are pretty much the same. I expect that the compiler will perform the same optimizations on both pieces of code and two end results may well be identical. From a programmers perspective though, the two pieces of code are far from equal.