Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > dc961633e8199690ddd4febf27e4f85b > files > 9

nil-000516-24mdv2010.0.i586.rpm


These are a few of the rules that I have tried to follow coding NiL:

* Naming conventions:
 - Types are Capitalized.
    Wrong:   class mouse
    Correct: class Mouse
   
 - Constants are ALL CAPS.
    Wrong:   const int lt_debug=1;
    Correct: const int LT_DEBUG=1;
 
 - Everything else is all lower case.
    Wrong:   int Things();
    Correct: int things();
 
 - Combined words are separated by _ NOT by caps.
    Wrong:   int doThingsNow();
    Wrong:   int dothingsnow();
    Correct: int do_things_now();
  
 - Don't shorten words, type it all out.
    Wrong:   bool kb_init;
    Correct: bool keyboard_initialized;
 

* Indention:
 - Use tabs at the start of line for indentation.
 
 - If not at start of line use spaces.
 
 - Use One True Bracket Style:
   
  This is wrong:
   if (42) 
   {
      do_things();
   }
   else
   {
      do_other_things();
   }
   
  This is wrong:
   if (42) 
    {
      do_things();
    }
   else
    {
      do_other_things();
    }
   
  This is correct:
   if (42) {
      do_things();
   } else {
      do_other_things();
   }
   
   
* Misc:
 - Try to move the actual #includes to the .cpp files,
   this limits overall compile time (especially with STL headers)
   and also limits the number of files that need to be recompiled
   when a header file changes:
   
   In the case of classes do this:
   
   class Other_class;
   class My_class {
      ...
      Other_class *other_instance;
      ...
   }
   
   and then other_instance = new Other_class; in the contructor of My_class.