Commenting Code

I have never had a ‘standard’ in mind on commenting code. There are principles that one should think of, such as method names should be descriptive enough that comments don’t necessarily have to repeat what method names communicate.

I found this great post by Eric Lippert. There are a few things I like about what he did:

  1. One knows the reason for a method. It doesn’t exist arbitrarily. It links to functionality that should exist as defined by the spec.
  2. Promotes single responsibility principle, because a method should only do one thing, and exist for the purpose of doing that thing.
  3. It just makes someone’s code more understandable for when a new person gets on board. Better communication. This is good.

Patrick Kayongo

I create and maintain software. Pan-African.

Johannesburg, South Africa