The worth of comments

Irmen de Jong irmen.NOSPAM at xs4all.nl
Sat May 28 21:49:22 EDT 2011


On 29-5-2011 2:47, Gregory Ewing wrote:
> Irmen de Jong wrote:
> 
>> I don't see how that is opposed to what Grant was saying. It's that these 'contracts'
>> tend to change and that people forget or are too lazy to update the comments to reflect
>> those changes.
> 
> However, I can't see that deleting the comment documenting the
> contract can be the right response to the situation.
> 
> If the contract comment doesn't match what code does, then
> there are two possibilities -- the comment is wrong, or the
> code is wrong. The appropriate response is to find out which
> one is wrong and fix it.

Fair enough.

Certainly I won't be deleting every source code comment encountered from now on, but I
do think we should keep in mind the risks already mentioned. In some situations I can
very well imagine it is best to simply delete any comments and go with just the code.


> If you simply delete the comment, then you're left with no
> redundancy to catch the fact that something is wrong.

You are right, if you don't have a Unit test for it.
Then again, faulty unit tests are a problem in their own right...

Irmen de Jong



More information about the Python-list mailing list