I've been watching the recent 'discussion' on coding conventions with some interest. I promised myself I'd stay out of it, but in the end I just can't. I guess I'm weak that way.
When discussion coding conventions we first need to understand *why* they are important. What are coding standards really for? This is an honest question and I'd recommend that before you read much further you stop and try to answer the question for yourself. Over the years I've heard many justifications for coding standards, but only one, in my opinion, is of much real value. Coding standards are not to make 'everything look the same' (the code may look more similar, but that isn't the real goal), they are not to protect coders from making stupid typographical errors (they might, but that isn't their primary purpose). The real purpose for coding standards to IMPROVE SOFTWARE MAINTAINABILITY. Coding standards don't equate to improved maintainability, but they are an important component. Maintainable code has the following attributes: 1) Readable (legible) 2) Understandable 3) Modifiable Readability is related to the textual formatting of the source code. It involves indentation, bracing styles, naming conventions, etc. Outside of entries to the IOCCC (International Obfuscated C Coding Contest), someone one reading code shouldn't have to spend much time trying to figure out if a statement really belongs inside an if block or not. Understandability relates to readability in that readable code is more likely to be understandable, but it involves much more than that. Understandability is the attribute of being able to read a section of code and understand what that code is supposed to accomplish and how it accomplishes it. Understandability relies not only on the code logic being clear but also relies heavily on source code documentation in the form of comments. Understandability can be measured on many levels. For example, what does a given loop accomplish, what does a given method do, what is this class for, how does this class fit into the application as a whole? All of these are questions of understandability. Modifiable code is the opposite of 'brittle' code. Brittle means that a small and seemingly benign change may have huge or catastrophic impact on the system as a whole. Developers are more comfortable making fixes or enhancements to modifiable code because is there is less chance that their changes will have unexpected impacts. Understandable code leads to improved modifiability because obviously developers are less likely to break code that they can readily understand, but it involves much more than this. Modifiability is more about proper design (OO methods, design patterns, etc.) then about the specifics of language syntax or text formatting. Coding conventions can be an important part of developing readable and understandable code. But, when codifying a set of conventions to impose upon developers, it is important to understand how each convention relates to improving maintainable code and then discarding those that really have no direct bearing. Otherwise, the coding conventions are simply one set of developers imposing their will upon the majority by virtue of nothing other than their position of power. I've rambled on longer than I intended so let me finish with two examples to demonstrate. One will be an example of a common coding convention that should be discarded because it does not directly impact maintainability and other is a convention that actually is important. First, bracing formats. As long as a given module follows a consistent strategy for using braces the specifics of that strategy are irrelevant to any rational coding convention. Each developer may have their own pet formatting that they believe is the 'most readable' but in reality, as long as a module uses a consistent format any developer who claims to be a professional in this business should be able to read it with little trouble. Now a simple convention that really is important. Don't define or initialize more than one variable on a single line. Why? Because it reduces readability by making it harder to see at a glance the type or value of a variable. It also impacts modifiability because it is easy to overlook an assignment that's buried in with several others on a single line so a change to code may have unexpected results. OK, that's enough for now, I need to go back to trying to keep my day job. But please, stop debating where the damn braces go, stop trying to impose a strict set of all encompassing rules that apply to all of Jakarta. Focus on defining a small set of basic rules that actually have a real impact on code maintainability and leave it at that. I have a set of coding guidelines that I recently developed for Java developers within my company. At some point, when I have some time, I'll see about removing the Apropos specific stuff and post it here for discussion. Marc Saegesser =============== The information contained in this message is confidential and is intended for the addressee(s) only. The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden. If you are not the intended recipient, please notify the sender of the delivery error by replying to this message, and then delete it from your system. - Apropos Technology. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>