Traditionally, the names of template types are just a single upper-case letter:
template<class A, class B, class C> class Foo {};
But I hesitate to do this because it's non-descriptive and hard therefore to read. So, wouldn't something like this be better:
template<class AtomT, class BioT, class ChemT> class Foo {};
I also tend to think the following would not be a bad idea:
template<class ATOM, class BIO, class CHEM> class Foo {};
It makes them stand out (and also, it's upper-case letters again). What's your opinion?
Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).
A naming convention is a convention (generally agreed scheme) for naming things. Conventions differ in their intents, which may include to: Allow useful information to be deduced from the names based on regularities.
For C++ templates I have a couple of patterns
If there is just a single template parameter, I name it T (or U,V for nested templates).
When there are multiple parameters and the use is not immediately obvious then I use descriptive names prefixed with T. For example, TKey, TValue, TIdentifiier, etc ... This makes the parameters fairly easy to spot throughout the template usage.
I would avoid the all upper case version though. Most people use all upper case identifiers in C/C++ to represent a macro definition. Repeating that pattern for a template parameter is likely to confuse people down the road.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With