Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

Qpid C++ style guide

Qpid C++ follows this guide: http://geosoft.no/development/cppstyle.html

With the following amendments:

  • Rule 34: Qpid source files have .h and .cpp extensions.
  • Rule 71: Qpid uses 4 space indent, not 2. No tabs.
  • Rule 75, 81: Qpid allows (but does not require) else/catch to be on same line as preceeding }
  • Rule 11: Qpid does not add an underscore to member variable names.

And the following additional rules:

  • Rule q1: Unlike other blocks, the contents of namespace blocks are not indented to prevent excessive line splitting, and multiple namespaces may be opened or closed on a single line. For example:
    Code Block
    
    namespace qpid { namespace common {
    
    class SomeClass {
      void foo();
    };
    
    }} // namespace qpid::common
    

Debate and changes

The discussion on qpid-dev did raise debate about some points of the style guide. The exceptions and new rules above reflect:

  • Points that were agreed on the list.
  • De-facto style of the codebase as it stands today.

Anyone who feels strongly about further modifications to the style guide should:

  1. Raise the issue on qpid-dev.
  2. Get consensus among the active qpid C++ developers for the change.
  3. Reformat the entire qpid codebase to conform to the change.

If you are not willing to do step 3 then don't bother raising the issue

The sad fact is there isn't one. There should be, it is important. The reason there isn't is because I can find no single compelling guide to adopt so the options are:

  • Pick one at random, reformat the codebase.
  • Write a new one based on the de-facto style that's already there.

Neither option greatly appeals so for now the rule is: try to be consistent with what is already there, even if you don't like it much. Consistency is better than nothing.

At some point (soon) we'll have to take this issue seriously. If you have suggestions for style guides that you feel are particularly good, or any suggestions on this topic please post the qpid-dev list to get the ball rolling again.