|Home||Back to Index|
I read some amazing code today. From an OOP perspective, it was extremely well designed - small classes, short methods, little duplication, encapsulated, polymorphic, etc. It was also more sophisticated than anything that I’ve written recently; I learned some techniques from reading it.
There was only one problem with it - it had no comments.
Code can and should reveal intent through good design and careful naming. Comments in the body of a method are often a code smell. The same is not true for class and method header comments, though.
Especially with code that uses design patterns or advanced language features, comments are a must. Without them, we perpetuate the priesthood; only the guru can maintain his or her own code, as no one else can understand it.
Once martial artists reach a certain level, they are asked to teach less advanced students. Developers could benefit from this attitude. Those with other views should be forced to maintain their own code for eternity. ;-)