Table of contents
No headers
To improve readability, classes, functions, variables etc. should be named according to common guidelines. Follow these guidelines unless you are modifying existing code that uses a different naming scheme.
Guidelines for C code:
- All function and variable names should be lower-case.
- All functions that are part of the public API should start with gmx_. Exported symbols that are only used internally by the library should start with _gmx_. UPDATE: it would be better to use a trailing underscore for internally used symbols, as that does not conflict with the C/C++ standard.
- Preprocessor macros should be all upper-case. Do not use leading underscores, as all such names are reserved according to the C/C++ standard.
- Name include guards like GMX_DIRNAME_HEADERNAME_H.
Guidelines for C++ code (if different from C code):
- Namespace names should be lower-case.
- Use CamelCase for all names. Start type names with a capital letter, and other names (functions, variables) with a lower-case letter.
Points for discussion:
- There are some other conventions currently used in the code, e.g., for boolean variables (bOk), enum values (e...), etc. Should we document these as well? Or change something there?
- Should we have common guidelines on how to name abstract base classes and interfaces? Currently, the code in master uses an "Abstract" prefix and an "Interface" suffix, respectively, but these can result in quite verbose code. Another common approach is to use a leading "I" for interfaces.
- Should we keep variable names all lower-case also in C++ code to keep in line with the C code we now have?
- There was some discussion about naming accessor functions and associated variables, but there wasn't any conclusion, so we could discuss this as well. Some options are:
- Currently, most code in the master branch uses foo(), setFoo(), and foo_. Some rationale.
- The foo() method, which is used most often, is as short as possible.
- In methods, it's immediately clear which variables come from the object and which are local to the function.
- We can keep the getFoo names for methods that are called like getFoo(&foo1, &foo2);
- The extra underscore might disturb people, but for code that would get cluttered by them, it's possible to declare a local variable without the underscore.
- Leading underscores were used at some point, but some guidelines suggest against it because it is easy to confuse them with reserved names in the C/C++ standard, so everything has now been changed to use a trailing underscore instead.
- Use getFoo(), setFoo(), and foo.