home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / lyx-0.13.2.tar.gz / lyx-0.13.2.tar / lyx-0.13.2 / development / Code_rules / Recommendations < prev    next >
Text File  |  1998-04-23  |  2KB  |  64 lines

  1. These are some rules for effective C++ programming. These are taken from 
  2. Scott Meyers, and is presented in their short form. These are not all the 
  3. rules Meyers presents, only the most important of them. LyX does not yet 
  4. follow these rules, but they should be the goal.
  5.  
  6. - Use const and inline instead of #define
  7.  
  8. - Use the same form in corresponding calls to new and delete,
  9.   i.e. write delete[] obj; if new obj[n]; was used to create
  10.   the object and write delete obj; if you wrote new obj;
  11.   Notice strings should be LString's instead of char *'s.
  12.  
  13. - Define a copy constructor and an assignment operator for all
  14.   classes with dynamically allocated memory.
  15.  
  16. - make destructors virtual in base classes.
  17.  
  18. - assign to all data members in operator=.
  19.  
  20. - strive for class interfaces that are complete and minimal
  21.  
  22. - differentiate among member functions, global functions and friend
  23.   functions.
  24.  
  25. - avoid data members in the public interface.
  26.  
  27. - use const whenever possible
  28.  
  29. - pass and return objects by reference instead of by value
  30.  
  31. - choose carefully between function overloading and
  32.   parameter defaulting.
  33.  
  34. - never return a reference to a local object or a dereferenced
  35.   pointer initialized by new within the function.
  36.  
  37. - use enums for integral constants.
  38.  
  39. - minimize compilation dependencies between files.
  40.  
  41. - pay attention to compiler warnings
  42.  
  43. - differentiate between inheritance of interface and
  44.   inheritance of implementation.
  45.  
  46. - differentiate between inheritance and templates
  47.  
  48. - know what functions C++ silently writes and calls.
  49.  
  50. - ensure that global objects are initialized before they are used.
  51.  
  52. --------
  53.  
  54. S. Meyers. Effective C++, 50 Specific Ways to Improve Your Programs and 
  55. Design. Addison-Wesley, 1992
  56.  
  57. ==================================
  58.  
  59. And one of mine:á(Lgb)
  60.  
  61. - When swiching on enums, refrain from using "default:" if possible.
  62.  
  63.  
  64.