Best Practices / Clean Code Tips / micropost

Clean Code Tips (Week 3)

Hi there! A new weekend is coming. The weekly Clean Code Tips are here:

Clear and expressive code with few comments is far superior to cluttered and complex code with lots of comments. Rather than spend your time writing the comments that explain what you’ve made, spend it cleaning your code

Choosing descriptive names will clarify the design of the module in your mind and help you to improve it. It is not at all uncommon that hunting for a good name results in a favorable restructuring of the code.

Short functions don’t need much description. A well-chosen name for a small function that does one thing is usually better than a comment header.

It is sometimes reasonable to leave “To do” notes in the form of //TODO comments. In that case, the TODO comment explains why the function has a degenerate or unfinished implementation and what that function should do in the future. Another good choice is to use FIXME comments.

Use searchable names: Single-letter names and numeric constants have a particular problem in that they are not easy to locate across a body of text

Special thanks to Ale Fantini, who added some new Clean Code ideas. Everybody is invited to share more tips.
All tips have been taken from Robert Martin’s Clean Code book

You will find a new post on December 21, since I’m on vacation the next week

Advertisements

Leave a Reply

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s