# Changes between Version 21 and Version 22 of CodingRules

Ignore:
Timestamp:
Nov 29, 2013, 10:51:08 AM (5 years ago)
Comment:

--

### Legend:

Unmodified
 v21 0. Curly braces are *always* on a single empty line (this gives a clear structure to the code), although in *switch* statements. No comments on the line with the opening brace. Put them above (e.g. the if-clause) or below in the next line. 0. *goto* is a no-go, it breaks the structure of the code (check google for details) 0. Global variables are a no-go as well. Look at root, then you know what I am talking about. 0. Try to avoid filling the global namespace with enums. Make them class members or create a namespace for them. 0. In switch statements the *case* label is on the same level as the *switch*. The corresponding code or brackets are indented. 0. There is only one command per line. In if conditions the command to be executed is always on a new line, the *else* is always on it's own empty line. 0. Try to avoid code repetitions. Invent a new function instead. 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...}}} instead of {{{new TFile; gFile->...}}} 0. *same* is TGraphs is done by omitting the A (A means *with axis*) 0. Try to avoid pointers, use objects, except if you add them to a root list.