coding style update

- Adhering to itself now (English!).
- Removed Adrian's private preferences for weird indentation rules.

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1309 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
hsc
2012-06-06 14:27:14 +00:00
parent ed463b71d6
commit be7b519346

View File

@ -1,81 +1,80 @@
- Sprache (Kommentare, SVN-Commits, Frickeleien): ausnahmslos Englisch Coding Style for Fail*
======================
- Einrückung: 1 Tab (entspricht 4 Spaces), bei Statements die bündig besser zu You may violate/break any of the following rules if you have a good reason to
lesen sind, ist eine Aufweichung möglich, Beispiele: do so, e.g., if readability is notably enhanced.
cout << "The counter value is: "
<< value;
if (first_looong_condition &&
second_looong_condition) { // oder für while/for/...
...
- Namenskonventionen: - Language (comments, SVN commit messages, "temporary" stuff): English
* Code-Dateien: .cc (Source), .hpp (Header), .ah (Aspect-Header), MixedCase (without exception)
* Namespaces klein
* Klassen fangen mit Großbuchstaben an, dann MixedCase
* Public-Members beginnen mit Kleinbuchstaben, dann MixedCase
* Private & Protected-Member beginnen mit "m_", globale Variablen mit "g_"
* Präprozessor-Direktiven immer groß; Include-Guards für Datei MyFooBar.hpp
gemäß __MY_FOO_BAR_HPP__
* Konstante Variablen ebenfalls immer groß
* Keine Konvention für lokale Variablen
* typedef's-Bzeichner gemäß
typedef std::whatever<type> good_name_t
- Kommentare - Naming conventions:
* Doxygen-Kommentaren: * Source files: .cc (Source), .hpp (Header), .ah (Aspect Header), MixedCase
~ Detailiert für alle Public-Member (bzw. Funktionen), also Parameter, * Namespaces: lowercase
Return-Wert, Seiteneffekte, ... * Classes: MixedCase, starting with uppercase letter
~ In Kurzform für Private/Protected-Member * Public members: MixedCase, starting with lowercase letter
~ An jedem Beginn einer (Aspekt-)Header-Datei: @brief * Private & protected members: starting with "m_"
~ Alle structs/classes/enums (und deren Elemente!) * Global Variables: starting with "g_"
* bei kompliziertem Kram (z.B.: drei verschiedene Datenstrukturen, zwischen * Preprocessor macros: uppercase
denen Events innerhalb von EventList hin- und herwandern können) gibt es - Include guard for MyFooBar.hpp: __MY_FOO_BAR_HPP__
Kommentare nicht nur zum "was passiert hier", sondern auch zum "warum * Constant variables: uppercase
machen wir das so" * (no convention for local variables)
* Innerhalb von Methoden/Funktionen "normale" C/C++ Kommentare (//, /**/) * typedefs: lowercase, underscores (good_name_t)
* Keine Autorennamen oder Datum, etc. in den Code-Dateien vermerken
- Formatierung - Comments:
* Direktiven für bedingte Kompilierung beginnen ganz vorne, außer bei * Doxygen comments:
eingerückten Anweisungen: - In detail for all public members (parameters, return value, side
private: | ... effects, ...)
int m_Bar; | #ifndef __puma - (At least) Briefly for private/protected members
#ifndef __puma | extern int g_Foo; - At the top of each (aspect) header file: @brief
boost::thread* m_pThread; | #endif - For each complex data type (and its elements)
#endif | ... * Explain *nontrivial* program logic not only by describing the "what's
... happening here", but also the "why are we doing it this way".
Zur Verdeutlichung kann ein #endif mit "// !puma" beendet werden (bei * Use "normal" C/C++ comments within functions (//, /**/).
großem vertikalem Abstand) * No author names, creation dates, change logs etc. in source files.
* Einrückungsbreite: 100 Zeichen That's why we're using a VCS.
* public/private/protected werden 1-mal eingerückt, Methoden/Var. ebenfalls
class pferd { - Formatting:
public: * Indentation: 1 tab (tabstop at 4 spaces)
void eier(); - may be relaxed / mixed with spaces for better readability of
multi-line statements, e.g.:
<TAB>cout << "The counter value is: "
<TAB> << value;
<TAB>if (first_looong_condition &&
<TAB> second_looong_condition) {
<TAB><TAB>...
* Preprocessor directives start in column 1.
* Max. line length: 100 characters.
* "public"/"private"/"protected" has the same identation as its surrounding
"class Foo" statement (we'd waste one indentation level for every class
definition otherwise):
class Foo {
public:
<TAB>void doSomething();
} }
Bei switch/case/namespaces: Similarly (and for the same reason) for namespaces and switch/case
statements:
switch (foo) { switch (foo) {
case 1: case 1:
... <TAB>...
} }
* Blöcke: '{' in derselben Zeile mit einem Space davor (namespace, class, * Compound statements (blocks): <Space>+'{' in the same line as its
if, while, for, ...) governing control structure (if, while, for, switch, try) or
namespace pferd { namespace/class definition:
... if (something) {
<TAB>...
} }
* Bei Funktionsdefinitionen folgt die '{' in einer neuen Zeile, außerdem * Function definitions are an exception to this ('{' in a new line):
keine Spaces. Definition: | Declaration:
Definition: | Deklaration:
void myFunction(int i) | void myFunction(int i); void myFunction(int i) | void myFunction(int i);
{ | { |
... | <TAB>... |
} | } |
* Space zwischen Kontrollstruktur und Klammer zur Unterscheidung von * Control structure tokens ("if", "try", ...) are followed by a single
Funktionsaufrufen (für die Bedingungen keine weiteren Spaces): space for better disambiguation from function definitions:
if (...) { if (...) {
... <TAB>...
} else if (...) { } else if (...) {
... <TAB>...
} else { } else {
... <TAB>...
} }
* return ohne Klammerung