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.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s