next up previous
Next: TABs and spaces Up: C++ Previous: Comments

Naming conventions

Example:
 
Line, SavingsAccount
Reason:
Common practice in the C++ development community.
Example:
 
line, savingsAccount
Reason:
Common practice in the C++ development community.
Example:
 
MAX_ITERATIONS, COLOR_RED, PI
Reason:
Common practice in the C++ development community
Example:
 
getName(), computeTotalWidth()
Reason:
Common practice in the C++ development community.
Example:
 
analyzer, iomanager, mainwindow
Reason:
Common practice in the C++ development community.
Example:
 
template<class T> ... template<class C, class D> ... 
Reason:
Common practice in the C++ development community.
Example:
 
fileName; // NOT: filNavn 
Reason:
English is the prefered language for international development.
Example:
 
exportHtmlSource(); // NOT: exportHTMLSource();
Reason:
When the name is connected to another, the readbility is seriously reduced; the word following the abbreviation does not stand out as it should.
Example:
 
::mainWindow.open(), ::applicationContext.getName()
Reason:
For doing global variables separated from other.
Example:
 
class SomeClass {

 private: 

  int length_;

 public:

};

Reason:
This is important because class variables are considered to have higher significance than method variables, and should be treated with special care by the programmer.
Example:
 
i, j, k, ::objectForAllProject;
Reason:
Scratch variables used for temporary storage or indices are best kept short
Example:
 
line.getLength(); // NOT: line.getLineLength();
Reason:
The latter seems natural in the class declaration, but proves superfluous in use, as shown in the example.


next up previous
Next: TABs and spaces Up: C++ Previous: Comments
2005-07-21