DISCOVER
X

Code Standards: Who Cares?…Right?

February 21, 2013 8:20 am Leave your thoughts
FacebooktwitterredditpinterestlinkedinmailFacebooktwitterredditpinterestlinkedinmail

If I remembered correctly during my university years there were very little reasoning provided for adhering to code standards apart from the occasional fear that we might lose mark. This is not the right attitude to be taught to budding programmers, it lacks the long term reasoning of software maintenance. Even experienced programmers forgot or not caring about this. So let me explain some of the practical advantages.

Readability

Most people like consistency, it’s the same with reading newspaper articles or a novel, you would expect standard line spacing and headings. In case of programing, consistency lies on the whitespacing standards and the braces position. For example, if you want to use BSD KNF style for your code then use it for the entire program, do not switch styles around. If you want to read more about braces styles click here

Search

Having standardised code makes in so much easier to search for a keyword in your code. For example: if we want to search for a function that does flat file parsing, instead of searching for both “parseFlatFile()” and “parse_flat_file” we’ll only need to search one of them.

Avoid duplication

Your IDE will be able to prevent duplications if you keep function and class names standard. It goes hand in hand with our search advantages.

Easier diff

Having consistent whitespacing will make diffs easier for when you have conflicts during code commits. Most diff softwares are smart enough to handle whitespace difference but on some occasion it can get problematic.

Documentation

Let’s face it, after about 2 months since developing your code, you are going to forget what exactly was happening back then. Applying standards for code commenting will help tremendously. Having proper docblock also helps your IDE to perform codehinting and clickthroughs.

The above are just a few of the advantages of applying and adhering to coding standards in your code. So let us all keep those in the back of our mind during our software development.

FacebooktwitterredditpinterestlinkedinmailFacebooktwitterredditpinterestlinkedinmail
Tags: , , , ,

Categorised in: ,