Changes between Version 15 and Version 16 of CodingRules
- Timestamp:
- 11/26/13 16:16:07 (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CodingRules
v15 v16 43 43 0. typedefs should end with a _t like UInt_t 44 44 0. Try to avoid code repetitions. Invent a new function instead. 45 0. Move code to their own function, If otherwise the structure gets too complicated. A typical example is "MyClass *ptr = new MyClass; CallFunction(ptr); delete ptr;" is much easier than "MyClass *ptr = new MyClass; if (...) { delete ptr; return; } if (...) { delete ptr; return; } delete ptr;" In a similar case "int i = Find(a);" with something like "int Func(int a) { for (int i=0; i<n; i++) { if (x[i]==a) return i; if (x[i]==a+1) return a+1; ... } return -1; }"then if you try to construct the same with breaks and variables declared outside of the for-scope.45 0. Move code to their own function, If otherwise the structure gets too complicated. A typical example is `"MyClass *ptr = new MyClass; CallFunction(ptr); delete ptr;"` is much easier than `"MyClass *ptr = new MyClass; if (...) { delete ptr; return; } if (...) { delete ptr; return; } delete ptr;"` In a similar case `"int i = Find(a);"` with something like `"int Func(int a) { for (int i=0; i<n; i++) { if (x[i]==a) return i; if (x[i]==a+1) return a+1; ... } return -1; }"` then if you try to construct the same with breaks and variables declared outside of the for-scope. 46 46 47 47