> Code should be self readable, and if you get
> to the point where it isn’t, then you may have
> to rewrite few bits. This is not always
> possible though, especially for temporary
> hotfixes or hacks. In this case, comments are
> a must.
* Sometimes business decisions may not make
logical sense, but someone says "do it this
way." It makes sense to comment this in the
code.
* The code might tell you what it's doing, but
not necessarily why it's doing it.
* You may be making use of legacy components that
you are unable to rewrite. It may make sense to
comment on their use within newer code that
interfaces with them, making it possible for
people to bugfix the interface without needing
to delve all the way into the legacy component.
Agree - but ideally these are just few exceptions. If these practices take over, then we may have a bigger issue to deal with and have a look at some serious refactoring of the infrastructure. e.g. too many legacy components may just require some rewriting or, if not possible, some kind of wrappers or facade patterns that makes the behavior self-readable (to the point where the legacy code is used).
* The code might tell you what it's doing, but not necessarily why it's doing it.
* You may be making use of legacy components that you are unable to rewrite. It may make sense to comment on their use within newer code that interfaces with them, making it possible for people to bugfix the interface without needing to delve all the way into the legacy component.