-
Notifications
You must be signed in to change notification settings - Fork 126
Classes and Structs
-
Class naming: use PascalCase, also known as UpperCamelCase, for class naming:
ADIOS
,Transform
,Transport
.-
Don't
or
class filedescriptor : public transport { ...
class file_descriptor : public transport { ...
-
Do
class FileDescriptor : public Transport { ...
-
Don't
-
Class members naming: Continue to use PascalCase for all class members, function and data, however adding an additional
m_
prefix to denote data members:m_XMLConfig
,m_Shape
, etc. This method enables easy autocomplete of members in many editors as it's encouraged by the clang-format.-
Don't
class Transport { public: std::string Name;
-
Do
class Transport { public: std::string m_Name;
-
Don't
-
Structs: reserve structs for public member variables only, structs should not have member functions, derived classes (inheritance), or private members. Structs will using the the same naming convention as Classes, without the
m_
prefix on data members.-
Don't
struct Attribute { public: std::string m_Name; std::string m_Type; std::string m_Value; // Use a class instead void SetName( const std::string name ); };
-
Do
struct Attribute { std::string Name; std::string Type; std::string Value; };
-
Don't
-
Single header (.h) and source (.cpp) file per class: Example: class Transport must have
Transport.h
andTransport.cpp
only; do not define several classes in the same file. Define structs in single header file, ( e.g. Attribute in Attribute.h ). Exceptions:- Templates
- Nested structs (only used a few times)
-
enum
class