Repost of (relevant parts) of Tim Moore's original posting in another thread to keep things organized :-) With permission
Please use this thread for coding style discussions. Thomas ==== > File Naming > ----------------- > All filenames are all lower case. Header files end with the suffix .hxx, code > files get the prefix .cxx. (Preferably?) The filename is just the class name > that is defined therein, accordingly suffixed. (Preferably) Only one class is > defined per file. > I agree that file names should follow class names, and strongly disagree that their case should be different from the class. The current code base is pretty random about this. > Class names > ------------------ > Class names generally are nouns that communicate the function of the class. No > prefixes are used. Class names begin with an uppercase letter. > > NOTE: Currently there are a lot of prefixes like FG... I don't see the need > for them as that's what namespaces are for. > Pretty standard stuff. I strongly agree about namespaces. It's now 2007... I'm annoyed that my limited attempts to use namespaces were deleted from patches I submitted :) Really, the SG and FG all over the place are distractions. > Function naming > ----------------------- > Function names begin with a lowercase verb expressing clearly what the > function does, probably followed by further specifications. Can't argue with that :) > Variables > ------------- > The names of private attributes of a class begin with an underscore followed > by a lowercase letter, i.e. _pitch, _altitude > > Rationale: > If applied consistently for only this purpose, the underscore instantly > communicates the variable at hand as being private to the class. I personally hate underscores or any other indication that a variable is a private member, with the rationale that a cursory reading of a well-written class will quickly give you that information anyway, but I know that the guardians of coding taste disagree with me. > Braces > ---------- > Opening braces are on the same line as the preceding statement (function > declaration, if clause, etc.). Closing braces follow a newline and are > properly indented to align with the block they close. > I mostly agree, except for function definitions. That is just not a very widespread style. > Indentation > --------------- > The code uses 4 spaces for indentation. > > Rationale: > As tab size is dependent on personal configuration and therefore > unpredictable, only spaces are allowed to indent code blocks. 4 spaces is a > compromise between readability and screen space used. > Agreed, and I don't have much sympathy for those who want to view the code with some other indentation. Anyway, if you're going to adopt a coding style, you might as well adopt one that is familiar to most practitioners of the language, as is the one described here. However, it's easy to overestimate the importance of a uniform coding style. Experienced developers must adapt to different styles in course of their work, and this is not difficult as long as individual files or "modules" are written in a good, consistent style. It is surely in terrible taste to start coding away in a file in a different one from the one that already exists there, even if the new style is the "official" one. Tim ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel