Coding Standards
Coding standards are helpful in creating good code. Most people think of coding standards in terms of layout suc as tabs vs spaces or where do we put our braces?
We start hearing suggestions to just let the beautifier or pretty print function take care of that for us. Indeed, we have tools to make things look cleanly indented.
There is more to a coding standard than how it looks. A consistent look does make it easier to see what is happening, but standards go beyond that.
A well constructed coding standard encourages good behavior and details problematic styles to avoid.
My personal favorites are
Google C, but that is no longer on-line. They only stress about C++.
Barr, which has a few things I prefer over Google.
I forgot I also have Ganssle's A Firmware Development Standard in my library of printouts.
The Gannsle standard is as much about directory structure and firmware best practices as it is about line by line style. We do see:
snake case
preferred tocamel case
lower case files naming to move between Linux/Unix and Windows.
Then there is the old function length - keep less than one page. I still like that, but I agree it might be a bit dated with a modern IDE and less paper listing. Still, if I can see it all on the screen, I don't have to hold it all in my mind.
Last updated