Saturday, September 5, 2009

Coding convention - C#

The importance of a standard coding convention is often ignored in many small and medium scale software companies. Most of the times, they make an effort to establish a convention but due to limited manpower and in absence of departmentalized role of employees, initial efforts either fade midway or the convention gets limited to documents. When there are developers coding, there should always be a mechanism to monitor their code. Like every other discipline, coding needs a constant monitor and review too.

Upon analyzing the code written over a number of years in our own organization, I decided to streamline the process and with reference from a number of guidelines used including the very own guidelines by Microsoft, I compiled a coding convention document for C#, to start with. I have also developed an easy and quick tool for developers to verify their own code against the convention. As developers have now started using the tool and it is constantly recording the data, I will be working on the reports soon using which it will be possible to crosscheck how effective this implementation has been.

I thought, maybe it is a good idea to share the details of my presentation and post the convention with possible explanation on this blog. It might be of some use to people looking for establishing their own standards. Hence I will be posting the details with explanation over this and next blogs.

Why coding convention?

If you are a developer, has any of these every happened to you?

Who wrote this code? What? It was me? ...But when?
Before I can fix anything, I have to contact the developer who wrote this code, to have this explained.
Does this code even work?
Where does this code start? And where does it end?

Well, based on what the software industry has to say, more than 80% of a software life cycle goes to maintenance. As Sun Microsystems puts it, hardly any software is maintained by its original author for its whole lifetime.

Many developers work on one project, even one module. Every developer has his/her own coding style. To bring uniformity and to get rid of the situations mentioned in italics above, it is important to set standards and ensure that they are followed. Following standards makes a huge positive impact on maintenance of projects.

The objective of setting coding standards is to have a positive impact on:
  • Avoidance of errors/bugs.
  • Maintainability, by implementing proven design principles and introducing uniformity of style.
  • Performance, by eradicating poor programming practices. 

We will start with naming conventions in next blog.

0 comments: