X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=development%2FCode_rules%2FRecommendations;h=4680beafa767fdc4c5f03ab620fcda55c3b7d5c9;hb=fbf4b51c7b2bb4bc355dcd0ae45cfdc277f8f1d8;hp=c08f95f9a76541879688de202ab87decc23efe32;hpb=eeaae9c35568b8852210420c727068a872ba3071;p=lyx.git diff --git a/development/Code_rules/Recommendations b/development/Code_rules/Recommendations index c08f95f9a7..4680beafa7 100644 --- a/development/Code_rules/Recommendations +++ b/development/Code_rules/Recommendations @@ -1,6 +1,6 @@ -These are some rules for effective C++ programming. These are taken from -Scott Meyers, and is presented in their short form. These are not all the -rules Meyers presents, only the most important of them. LyX does not yet +These are some rules for effective C++ programming. These are taken from +Scott Meyers, and are presented in their short form. These are not all the +rules Meyers presents, only the most important of them. LyX does not yet follow these rules, but they should be the goal. - Use const and inline instead of #define @@ -11,9 +11,10 @@ follow these rules, but they should be the goal. Notice strings should be std::string's instead of char *'s. - Define a default constructor, copy constructor and an assignment - operator for all classes with dynamically allocated memory. + operator for all classes with dynamically allocated memory that + do not inherit noncopyable -- make destructors virtual in base classes. +- make destructors virtual in base classes and only there. - assign to all data members in operator=. @@ -49,15 +50,22 @@ follow these rules, but they should be the goal. - ensure that global objects are initialized before they are used. +- avoid conditions to 'if' and 'while' that span more than a line + -------- -S. Meyers. Effective C++, 50 Specific Ways to Improve Your Programs and +S. Meyers. Effective C++, 50 Specific Ways to Improve Your Programs and Design. Addison-Wesley, 1992 ================================== -And one of mine: (Lgb) +And one of mine: (Lgb) - When swiching on enums, refrain from using "default:" if possible. +And one of mine: (Andre') + +- try to implement your class in a way that the automatically generated + copy constructor and copy assignment work out-of-the box. +