Most C++ naming conventions dictate the use of camelCaseIdentifiers
: names that start with an uppercase letter for classes (Person
, Booking
) and names that start with a lowercase letter for fields and variables (getPrice()
, isValid()
, largestValue
). These recommendations are completely at odds with the naming conventions of the C++ library, which involve lowercase names for classes (string
, set
, map
, fstream
) and names_joined_with_an_underscore
for methods and fields (find_first_of
, lower_bound
, reverse_iterator
, first_type
). Further complicating the picture are operating system and C library functions, which involve compressed lowercase names in C and Unix and functions starting with an uppercase letter in Windows.
As a result my code is a mess, because some identifiers use the C++ library, C, or operating system naming convention, and others use the prescribed C++ convention. Writing classes or methods that wrap functionality of the library is painful, because one ends with different-style names for similar things.
So, how do you reconcile these disparate naming conventions?
One way it to adopt the C++ naming_convention
, this is what most code examples in the literature do nowadays.
I slowly see these conventions move into production code but it's a battle against MFC naming conventions that still prevail in many places.
Other style differences that fight against old standards are using trailing underscores rather than m_
to denote members.