Programming Conventions

From KratosWiki
(Difference between revisions)
Jump to: navigation, search
Line 49: Line 49:
== Local Variables ==
== Local Variables ==
[[Category: References]]

Revision as of 16:15, 8 January 2010

Imposing a standard usually is restrictive and annoying. But having a coding convention can help in understanding better and faster the code written by a team or even by only one programmer. The coding convection used in Kratos are described briefly in following sections.



Class names must be in lower case except the first letter of each word in upper case as separator. For example:

 class MyClassNameExample

Try to describe the type of the class with its name. Some typical cases are:

  • Elements name must be finished with Element word:
 class MyShellElement
  • Conditions name must be finished with Condition word:
 class My2DLoadCondition
  • Linear solvers name must be finished with Solver word:
 class GmresSolver
  • Application classes must be started Kratos and finished with Application :
 class KratosStructuralApplication

It can be seen that in all cases only the first letter of each word is in capital. It's important to mention that there is NO initial letter (like "C") to distinguish a class.

Class Members

Class members are in lower case with first letter of each word in capital starting with following prefixes:

  • lower case m to indicate that they are member variables:
   int mNumberOfElements;
  • lower case mp to indicate that they are member pointers:
   Node::Point mpFirstNode;
  • lower case mr to indicate that they are member references:
   Matrix& mrLocalMatrix;

Class Methods


Macros in Kratos are all uppercase with underline "_" as seperator and always starting with KRATOS_ as prefix:



Local Variables

Personal tools