[pet] PET style guide proposal

Mülner, Helmut helmut.muelner at joanneum.at
Fri Jul 2 11:41:20 CEST 2010


Hi Bernd,

 > I added a ProgrammingStyleGuide Wiki page to pet.opendfki.de. The
 > content stems from the Google style guide and other sources, only
 > very little of it are my own ideas and opinions.

>From the suggested naming conventions:

 > - data fields should start with an underscore, especially private ones 

This is a little problematic because it conflicts with the C++ standard
(see e.g. http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-a-c-identifier)

Some of the currently used member names (_A, _L, _Chart, _LI, _Cp_span, _G) are not standard conforming.
The typename type_t also is illegal and should be replaced by "int", because in the current version the type
is not enforced and mixed with int (e.g. dag_arc::attr).

 > - Avoid long names, if possible 

I strongly disagree.

 > -  The shorter the name of a variable, the smaller its scope! 

>From this rule follows that names with a large scope should be long,
they also should be self-describing!

I also want to suggest the following recommendation:

Prefer using prefix -- and ++, instead of postfix (from Herb Sutter: "Exceptional C++ Style", p.6).
Espescially iterator should use prefix increment wherever possible.
This is broken in pet: Some self defined iterators even lie: they use operator++(int) to implement
a preincrement operation. (see also: http://stackoverflow.com/questions/24901/is-there-a-performance-difference-between-i-and-i-in-c).

Recommended reading: Herb Sutter, Andrei Alexandrescu: C++ Coding Standards, 101 Rules, Guidelines, and Best Practices.

Best regards

Helmut





More information about the pet mailing list