Comments versus tests?
When I read this article, I was struck by the
strong parallel between comments and unit tests.
Both are meant to capture and explain the code's
functionality. Granted, comments are usually
easier to read than tests are. On the other hand,
when you run tests, you get an immediate
indication of whether the tests and the code still
agree, which is not that easy to do with comments.
There's a "comment first" coding methodology,
which the author talked about, and there is also a
"testing first" methodology, which a lot of people
follow (and I find to be very useful). Plus, with
open source unit testing frameworks (like <a
it's getting easier to use unit testing for
open source projects.
Has anyone else seen the uses of comments and
tests overlap in their coding?