Difference between revisions of "Documentation/4.0/Developers/Style Guide/Cpp"

From Slicer Wiki
Jump to: navigation, search
Line 1: Line 1:
 
{{documentation/underconstruction}}
 
{{documentation/underconstruction}}
 +
 +
= Indentation =
 +
Configure your text editor to do VTK style indentation:
 +
* [http://www.vtk.org/Wiki/Elisp_Code_for_VTK-Style_C_Indentation Emacs]
 +
* [http://wiki.na-mic.org/Wiki/index.php/User:Pieper Vi/Vim]
 +
* [http://www.vtk.org/Wiki/VTK_FAQ#How_do_I_get_my_C.2B.2B_code_editor_to_do_VTK-style_indentation.3F Visual Studio]
 +
 +
= Naming =
 +
* Local variable should start with a lower case.
 +
** For example:
 +
 +
void vtkSlicerSliceLogic::SetForegroundLayer(vtkSlicerSliceLayerLogic *ForegroundLayer) // wrong!
 +
 +
should be
 +
 +
void vtkSlicerSliceLogic::SetForegroundLayer(vtkSlicerSliceLayerLogic *foregroundLayer)
 +
 +
* Member variable should start with a capital letter, and in implementation should be used in conjunction with 'this->' convention
 +
** For example
 +
 +
class Node {
 +
  Object &Foo();
 +
  Object Bla;
 +
};
 +
Object& Node::Foo()
 +
{
 +
  return this->Bla;
 +
}
 +
  
 
= References =
 
= References =

Revision as of 13:56, 9 April 2012

Home < Documentation < 4.0 < Developers < Style Guide < Cpp


Indentation

Configure your text editor to do VTK style indentation:

Naming

  • Local variable should start with a lower case.
    • For example:
void vtkSlicerSliceLogic::SetForegroundLayer(vtkSlicerSliceLayerLogic *ForegroundLayer) // wrong!

should be

void vtkSlicerSliceLogic::SetForegroundLayer(vtkSlicerSliceLayerLogic *foregroundLayer)
  • Member variable should start with a capital letter, and in implementation should be used in conjunction with 'this->' convention
    • For example
class Node {
  Object &Foo();
  Object Bla;
};
Object& Node::Foo()
{
  return this->Bla;
}


References

Tools