About coding conventions

Coding conventions are an important part of software development.

Contrary to popular belief, it is not only the functionality of the code that matters, what the code does, but also the readability, what the code looks like. That is because code is read much more often than it is written. If, within a team or organization, everybody formats his code differently or uses different naming conventions, that is a recipe for disaster.

People have debated for ages about using tabs versus spaces and how many of them, but what is more important is consistency. When existing code uses tabs, keep it this way. When you start from scratch, you have a choice.

Code Conventions for the Java Programming Language can be found at Oracle Technology Network. Python has a Python Enhancement Proposal (PEP) for this: PEP 8 — Style Guide for Python Code.

Developers should be familiar with these best practises and try to follow the rules. There are tools to help you with this. For example, Pylint for Python and Checkstyle for Java. However, as PEP 8 points out, it is equally important to know when not to follow the rules. To be consistent with existing code, for example.

A good starting point is the Wikipedia article about coding conventions.


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