This article was originally posted as part of my old blog on Jan 18, 2013.

Great care should be taken to make code readable. This is no different from writing, say, prose. Similar principles apply. Use proper grammar and punctuation in comments. Keep things simple. Pick proper names. Keep the unit focused to a possibly a single responsibility. Keep things small.

In particular, understand that even a seemingly small careless mistake affects entire program. Perhaps, that sentence in the Javadoc comment is grammatically wrong but what does it matter? Code is still correct. Right? Not really. A mistake like that gives the impression that the code is not being maintained at the highest quality.

The visual aspects of a program are important too. Too many blank lines make an otherwise good program look ugly. Similarly, lack of blank lines at some places makes it look cluttered. Proper indentation is important as well. It is amazing how these two simple aspects - indentation and proper placement of blank lines, can make a huge difference when it comes to readability.

In short, a program should be a pleasure to read just like a book is expected to be.