June 14th, 2008

A note on standards …

These can be discussed for ever, or not at all – this tells you why.

More notes and there’s off course Sutter&Alexandrescu’s book.

And if you really must, boost has a nice summary.

It boils down to:
  • Use the naming conventions of the C++ Standard Library!

Sounds obvious – but what does that mean?

Here’s a few guidelines from that standard
  • Names (except as noted below) should be all lowercase, with words separated by underscores.
  • Acronyms should be treated as ordinary names (e.g. xml_parser instead of XML_parser).
  • Template parameter names begin with an uppercase letter.
  • Macro (gasp!) names all uppercase (and can have a prefix like “MYLIB_”)
  • Choose meaningful names – explicit is better than implicit, and readability counts. There is a strong preference for clear and descriptive names, even if lengthy.
  • Use fixed-width fonts.
  • Use spaces rather than tabs.
  • Limit line lengths to 80 characters.