New Years Resolution: Fewer Code Comments!
Recently I’ve been reading Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin). This is a must read, and I’d recommend it to programmers of all skill levels. It has reminded me of many things that I’ve mistakenly unlearned over the past few years as I’ve struggled to battle against tighter and tighter deadlines and push out as much functionality as possible.
One of the main points that I’ve taken from the book is that comments make programmers lazy. For some reason we seem to think we can name our variables anyway we like as long as we give them a nice descriptive comment. Likewise, instead of refactoring code into nice methods with expressive names that follow the Single Responsibility Principle, we tend to create long functions that do many things and again litter them with comments describing what we are trying to do. This leads to problems, as our comments can be misleading, without actually reading and understanding the code we don’t know what is really going on.
My new years resolution is to comment less. In fact, I plan to write as few comments as I can. Instead I will concentrate on writing expressive code that speaks for itself. This will lead to some quite lengthy function and variable names, but I’m a fast typer. So do you think comments make you lazy? Or are they a necessary evil or the limited expressiveness of our high level languages?
