Skip to content

Naming conventions and folder structure

Robin Bardakcioglu edited this page Aug 2, 2016 · 3 revisions

Namespaces and user defined names

Namespaces

Namespaces are CamelCase. Namespaces should represent logical parts of the code, for example all classes and functions that implement a specific method or functionality should go into one namespace. The name of that namespace should be related to the contained method or functionality.

User defined types

User defined types, which includes class and struct names, should beginn with a uppercase letter. For multi-word names, CamelCase naming is used. Examples: class File;, struct ParticleProperties;.

Methods and free functions

Methods and free functions names should be lower case, and use underscore notation if they contain multiple words. They should include a verb if they do something. Example:

Data members

Data members should use underscores. E.g. struct Particle { int type_id; }; The name of private data members should start with m_, e.g. class A { int m_private_member; };

Folder structure and File names

File names

Files that contain class declarations and definitions should be name like the class. So for a class Foo, the definition goes into Foo.hpp, the implementation into Foo.cpp. Please use separate file per class.

Folder structure

The folder structure should follow the namespace structure. The names of the folders are the lower case, underscore versions of the namespace name. So if there is a class Espresso::Core::Foo::Bar, its header file should be core/foo/Bar.hpp.