# Used Code

Three + 1 most important rules for code readability

Posted in Software Development by gregory_vincic on March 31, 2010

Keeping your code readable is a key element of productive programing. Depending on which language you write your code in there are specific rules. E.g. SUN published in 1999 Code Conventions for the JavaTM Programming Language also IBM published a series of articles back in 2001 on perl programming, The road to better programming. Google has about 40 milion more hits on programming guidelines.

Most of us write code in at least three or four languages which could result in many coding styles to follow. Refactoring code is a way to really learn what counts for readability and what doesn’t. I found myself following couple of rules refactoring both my own and others code, making it more readable. I’d repeatedly do this

  1. Group variable declarations at beginning of block
  2. One statement / line
  3. New line spacing between blocks of code

When reading the code you can then skip the declaration part, usually nothing interesting happens there. The short one line statements and new line separated blocks of code are way easily read and understood.

Don’t forget the +1 rule

Have fun!

Follow

Get every new post delivered to your Inbox.