Posts

Showing posts from April, 2013

Empty lines and semantics in source code

I remember a couple of years ago, while working with some developers, one of them seemed to be irritated by seeing empty lines in source code. I think he was missing an important dimension of software: Readability. Grab a book nearest to you. Go ahead and do it. Grab any book close to you. Open it on any page. Are there any blank spaces between lines? If you didn't take a book for kids, empty lines will emerge like crack in the 80's making paragraphs easier on the eyes (instead of making them red). Speaking of the devil…

I feel better now*. Just as empty lines break ideas up in text books, empty lines in source code offer a new dimension for structuring code. It’s like something that the developer wants to say about the code. Almost like nonverbal communication. I’m exaggerating, but really, use empty lines to separate related lines of code when "extract method" gets to the limit.

Perfectly refactored code will have only one line per method, which is absolutely a boo…