|
|
<ol><li><strong>Naming:</strong> Classes will be initialized with an upper case letter, example: ( ADIOS, NETCDF, PHDF5, Transform, Transport, etc. ). <ul><li><code>Don't</code><ul><li><pre style="border: 0;"><code>class filedescriptor : public transport
|
|
|
{...</code></pre></li></ul></li><li><code>Do</code><ul><li><pre style="border: 0;"><code>class FileDescriptor : public Transport
|
|
|
{...</code></pre></li></ul></li></ul></li><li><strong>Members:</strong> Class member variables will 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. While member functions will have the same rules as regular functions (<em>e.g.</em> start with an upper case letter). <ul><li><code>Don't</code><ul><li><pre style="border: 0;"><code>class Transport
|
|
|
1. <strong>Class naming:</strong> always start with an upper case letter, example: ```ADIOS, Transform, Transport```.
|
|
|
* _Don't_
|
|
|
```cpp
|
|
|
class filedescriptor : 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).
|
|
|
|
|
|
* _Don't_
|
|
|
```cpp
|
|
|
class Transport
|
|
|
{
|
|
|
public:
|
|
|
std::string Name;
|
|
|
</code></pre></li></ul></li><li><code>Do</code><ul><li><pre style="border: 0;"><code>class Transport
|
|
|
|
|
|
* _Do_
|
|
|
```cpp
|
|
|
class Transport
|
|
|
{
|
|
|
public:
|
|
|
std::string m_Name;
|
|
|
</code></pre></li></ul></li></ul></li><li><strong>Structs:</strong> reserve structs for public member variables only, Structs should not have member functions, inheritance or private members. Structs will be initialized with an upper case letter and member variables won't use hungarian notation as classes. <ul><li><code>Don't</code><ul><li><pre style="border: 0;"><code>struct Attribute
|
|
|
|
|
|
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.
|
|
|
|
|
|
* _Don't_
|
|
|
```cpp
|
|
|
struct Attribute
|
|
|
{
|
|
|
public:
|
|
|
std::string m_Name;
|
|
|
std::string m_Type;
|
|
|
std::string m_Value;
|
|
|
void SetName( const std::string name ); // Use a class instead
|
|
|
// Use a class instead
|
|
|
void SetName( const std::string name );
|
|
|
}
|
|
|
</code></pre></li></ul></li><li><code>Do</code><ul><li><pre style="border: 0;"><code>struct Attribute
|
|
|
```
|
|
|
* _Don't_
|
|
|
```cpp
|
|
|
struct Attribute
|
|
|
{
|
|
|
std::string Name;
|
|
|
std::string Type;
|
|
|
std::string Value;
|
|
|
}
|
|
|
</code></pre></li></ul></li></ul></li><li><strong>Class Header and Source Files:</strong> Only allow one header and one source file per class ( <em>e.g.</em> class Transport in Transport.h and Transport.cpp), do not define several classes in the same file. Structs are always define in one header file, ( <em>e.g.</em> Attribute in Attribute.h )</li></ol> |
|
|
\ No newline at end of file |
|
|
```
|
|
|
|
|
|
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 ).
|
|
|
Exceptions:
|
|
|
* Templates
|
|
|
* Nested structs (only used a few times)
|
|
|
* ```enum``` class |