4 ms·
Very much disagree. > This reveals the fallacy that coding standards are built on – that there is some kind of one true way of programming, .... No, a coding
by ggchappell 14y ago
Very much disagree.
> This reveals the fallacy that coding standards are built on – that there is some kind of one true way of programming, ....
No, a coding standard establishes conventions for a project, so that people can more easily understand and maintain code written by others. Moving between coding conventions is jarring, and adjusting to it takes time & effort away from figuring out what code does or what is wrong with it.
Similarly, the fact that an entire novel (or website or ...) is set in a particular font does not mean that this is supposed to be the one true font; rather, consistency means we can simply read, and not be continually jarred by font changes.
- phleet 14y agoI completely agree with you. I've followed many different coding standards, none of which perfectly match what I use for my own code. Even if the coding standard was different in every way from what I like, it's still better than me doing it the way I want to and everyone else doing it their own way. Coding standards are not about choosing the "one true way", but about consistency, just like you say. Whenever I see anything in a codebase that breaks any convention (whether a programming language one, an idiomatic one, a naming convention or anything), I assume it breaks it _for a reason_, and that I need to investigate why. Having a consistent style also increases the usefulness of automated tools and search/replace.
- justanotheratom 14y agoAgreed. The author focuses on the right and wrong of things, but it is really about conventions. One could argue that opening brace on the same line makes code look more "natural", or opening brace on a new line makes it look more "symmetric". But instead of reasoning about which way is better or worse, one should focus on coming up with a rule that is prescriptive and covers all cases. For example, the "opening brace placement" rule should prescribe the position of the brace in all these cases (for C language): 1. if and for loops 2. Function definition 3. Switch statements
- tseabrooks 14y agoAgreed. Coding standards have nothing to do with "my way is better than yours". If you feel like they do, you should find new people to work with. It's all about being able to view code consistently. At my previous employer (Large consumer electronics company doing embedded dev) we had a LOT of old code, or code we had originally gotten from third parties. We also had a fairly exacting coding standard. The coding standard made groking the 3+ million lines of code running your average TV MUCH MUCH easier. However, if you came onto a file that was written for some other coding standard and you dropped code into it that didn't match the style of that specific file you would probably not get a thumbs up rom a code review. In that situation we all understood it was far more important for all of the old crusty code in third party libs to have the same style even if it didn't match out own internal coding standard. Reading bodies of code with different conventions sprinkled throughout adds needless complexity to the task.