Google’s Coding Style Guide

Regardless of personal preference you will often be forced to adapt to the coding style of someone else.  Generally this will be an enforced style at the company you work for.  Some see this as a minor annoyance.  I personally see this as important and practical.  It helps maintain code readability, this is important for new comers or looking back at your own code.  By making code more readable you also make it more understandable, this makes maintenance even easier.   Decision about style have more impact than arguments like whether braces should be on the same line.

The coding preference which most closely matched my habits turned out to be Google’s C++ Coding Guide.  This made most sense to me as I learned programming starting with C then C++.  In reality I started coding in BASIC on a Commodore 64 but that is a different story.

I find this style guide has a lot of good habits one can derive from it.

Google’s C++ Style Guide

There are some changes to the style I make, here are some important ones:

  • Class members are all prefixed with an underscore
  • Two spaces between functions implementations