Next Previous Contents

17. C++ Coding Standards

Coding standard is very essential for readability and maitainence of programs. And it also greatly inproves the productivity of the programmer. The GNU C++ compiler must enforce coding discipline. The following is suggested - inside class definition:

The compiler should generate error if the code does not follow above standard. The C++ compiler can provide a flag option to bypass strict coding standard to compile old source code, and for all new code being developed will follow the uniform world-wide coding standard.

In the sample code given below t stands for protected, v stands for private, m stands for member-variable and p stands for pointer.

class SomeFunMuncho
                int     mTempZimboniMacho; // Only temporary variables should be public as per OOP
                float   *mpTempArrayNumbers;
                int     HandleError();
                float   getBonyBox();  // Public accessor as per OOP design
                float   setBonyBox();  // Public accessor as per OOP design
                float   mtBonyBox;
                int     *mtpBonyHands;
                char    *tHandsFull();
                int     tGetNumbers();
                float   mvJustDoIt;
                char    mvFirstName[30];
                int     *mvpTotalValue;
                char    *vSubmitBars();
                int     vGetNumbers();

When your program grows by millions of lines of code, then you will greatly appreciate the naming convention as above. The readability of code improves, because just by looking at the variable name like mvFirstName you can tell that it is member of a class and is a private variable.

Visit the C++ Coding Standards URLs

Next Previous Contents