|
|
1. <strong>Class naming:</strong> always start with an upper case letter, example: ```ADIOS, Transform, Transport```.
|
|
|
1. **Class naming:** use _PascalCase_, also known as _UpperCamelCase_, for class naming: ``ADIOS``, ``Transform``, ``Transport``.
|
|
|
* _Don't_
|
|
|
```cpp
|
|
|
class filedescriptor : public transport
|
|
|
{ ...
|
|
|
```
|
|
|
or
|
|
|
```cpp
|
|
|
class file_descriptor : public transport
|
|
|
{ ...
|
|
|
```
|
|
|
* _Do_
|
|
|
```cpp
|
|
|
class FileDescriptor : public Transport
|
|
|
{ ...
|
|
|
```
|
|
|
2. <strong>Class members naming</strong> member variables: use hungarian notation ```m_``` prefix followed an upper case letter: m_XMLConfig, m_Shape. This method enables easy autocomplete of members in many editors as it's encouraged by the clang-format. Member functions will have the same rules as regular functions (<em>e.g.</em> start with an upper case letter).
|
|
|
1. **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_
|
|
|
```cpp
|
... | ... | @@ -26,7 +31,7 @@ |
|
|
std::string m_Name;
|
|
|
```
|
|
|
|
|
|
3. <strong>Structs:</strong> reserve structs for public member variables only, Structs should not have member functions, derived classes (inheritance), or private members. Structs will be initialized with an upper case letter and member variables won't use hungarian notation (```m_```) as in classes.
|
|
|
1. **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_
|
|
|
```cpp
|
... | ... | @@ -38,7 +43,7 @@ |
|
|
std::string m_Value;
|
|
|
// Use a class instead
|
|
|
void SetName( const std::string name );
|
|
|
}
|
|
|
};
|
|
|
```
|
|
|
* _Do_
|
|
|
```cpp
|
... | ... | @@ -47,11 +52,11 @@ |
|
|
std::string Name;
|
|
|
std::string Type;
|
|
|
std::string Value;
|
|
|
}
|
|
|
};
|
|
|
```
|
|
|
|
|
|
4. <strong>Single header (*.h) and source (*.cpp) file per class</strong>: Example: class Transport must have Transport.h and Transport.cpp only, do not define several classes in the same file. Define structs in single header file, ( _e.g._ Attribute in Attribute.h ).
|
|
|
1. **Single header (*.h) and source (*.cpp) file per class**: Example: class Transport must have ``Transport.h`` and ``Transport.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 |
|
|
\ No newline at end of file |
|
|
* ``enum`` class |
|
|
\ No newline at end of file |