We are developing embedded software for an automotive product in ANSI-C in a large team. Yesterday, in our regular code review, we had a general discussion about the style of our code. We have a coding guide line (roughly 30 pages), which mainly ensures certain required practices and besides that treats hungarian notation, level of indentation, newline strategy for code blocks etc.
The discussion yesterday was about, whether there should be more detailed guide lines for how the code is formatted. Example declarations:
int int1, int2 = 0; short short1; long_type_name_defined var1; const * type var2; type const* var3;
One colleague had the opinion, that there should be a clear guideline of how to consistently align the variables (e.g.: spaces up to longest regular type), whether or not there should be spaces between "*" and type / qualifier, where the qualifier is located, whether or not to use the "," operator etc. Things which could be somehow declared as a matter of personal taste.
- increased readability
- better to understand for "externals" (who are new to the code or typically not dealing with it)
- because it is somehow a matter of personal taste, what increases readability for one person, could decrease it for another (?)
- might be hard to clearly define
- style rule set would be enlarged a lot
- a lot of work to always follow a large rule set
The main question is somehow: Does it really help to have a very specific rule set? We could not find a clear consensus about that. A style guide should increase the readability/maintainability of code, so there will be some optimum between size of the rule set and "beauty" of the code (?).
I would like to get your opinions about where this optimum is.