The most explicit Mozilla coding standard I have been able to find is called the coding style guide and is found here: https://developer.mozilla.org/En/Developer_Guide/Coding_Style
It is however apparently not complete, and its more respected by some than others – I’ll come back with generic examples of this in coming posts.
Rather than just point my fingers at what I think is wrong I have chosen to attempt to start a debate of what we want to accomplish with our coding standard – because this is not clear to me at the moment and I think we need a debate on it. When we start to have a common understanding of why we want it, we can write this as the introduction to the coding standard, and we can go into a discussion of the individual rules and recommendations.
My primary reason for doing it this way is that, as long as we don’t have a well defined purpose with the coding standard it is more a question of who likes what or randomly joins a discussion, rather than a judgment of whether a given rule/goal will bring us closer to the overall goal.
Some example goals could be (note, these goals are examples, they might, or might not be what I think should be our goals, nor are they all the goals I could think of):
1a) Make code execute as fast as possible
1b) Make code easy to maintain
1c) Make code easy to write
1d) Make code look esthetically pleasing
It is my strong opinion that the overall goals for a coding standard shouldn’t be concrete things like:
2a) To have a common naming convention
2b) To keep code complexity down (for any of the ways to measure complexity)
2c) Make code compile as fast as possible
2d) Automate as much as possible since these are ways to accomplish overall
goals, like “2a) To have a common naming convention” could be a way to get “1b) Make code easy to maintain” but it isn’t a goal in it self.
I have cross posted this to both my blog (developer.mikek.dk) and mozilla.dev.platform to maximize exposure – discussions are welcome in both forums, but I recommend we keep it to the newsgroup for now – I’ll try to keep a summary on the wiki at https://wiki.mozilla.org/Purpose_of_coding_standard