Defining a Coding Standard

One of the first step a company must take is defining a coding standard, and possibly the last. The web and books are full of coding conventions, but you might want to specializes it.

This topic is already heavily discussed in the community, still I think other criteria must be taken into account. Most Coding Standard (CS) limit themselves to describe naming convention, global usage of language features, … Those aspects are important, but I would like to introduce others. CS should remove all formatting’s personality of programmers, not just naming. The goal is to remove unwanted noise. Space count, variable declaration position, method ordering, if they are different from one programmer to another it can create a huge noise factor. This also means that access to the logic gets harder. That does not mean programmers have no freedom, I simply prefer freedom applied on design and algorithms. The goal is not being repressive, but to ease access to other’s code.

The next point I consider fundamental is the parsability of a CS. In a competitive environment, productivity tools can really help being on time. Imagine the comfort of “one-click” functionality such as generating an empty test case for every method in your class, generating accessors for a variable, adding missing headers. Writing those tools can be cumbersome if the CS is ambiguous like in some naming convention. I don’t want to write a fully-fledged recursive-descent C++ parser, I just want to create a unit test case. One requirement is then that all signatures, class name, files path should be easily found by a simple parser in most part of the code.

As the CS must be adopted by all programmers, try to keep it as a global philosophy. Never create a rule without a valid explanation. Open all rules to discussion and if it needs to be changed, don’t hesitate to do it. Include your team in the discussion, it is fundamental. Finally, you are going to live with it for a moment, so everybody must feel confortable with it.

  • Reader

    Great! Thank you very much!
    I always wanted to write in my site something like that. Can I take part of your post to my blog?
    Of course, I will add backlink?

    Regards, Reader

  • julien.hamaide

    Sure! While I’m interested in what you’ll write, I’m not sure I will be able to read it ;-)