Fix Bug 363586 - Kmail2 handles mailto: incorrectly. urlencoded does not work
[kdepim.git] / kalarm / CODING_STYLE
blob52074e23a1d2d014b084bbe9ef9becab11430278
1 KAlarm coding style
2 ===================
4 KAlarm code should adhere to the following stylistic rules.
6 SPACING
8 - No tabs.
9 - Indent with 4 spaces.
10 - No spaces inside round or square brackets.
11 - No space between a function name and the bracket following.
12 - Place '*' and '&' immediately after the type in declarations, followed by a
13   space, e.g. "const QString& from", "char* str".
14 - Normally two spaces on each side of "&&" and "||" in "if"/"while"/"for"
15   statements.
16 - Indent "case" within "switch" statements.
18 BRACES
20 - Opening brace on a new line.
21 - No braces are used when only a single statement follows 'if', 'for' etc.
23 SPLITTING LINES
25 - There is in general no need to split lines less than 120 characters. Beyond
26   that length, it's at the coder's discretion.
27 - Conditional statements occupying line lengths less than 120 characters may be
28   split for clarity.
29 - Long "for" statements should be split before each clause at least.
30 - If a function call or declaration has to be split over more than one line,
31   indent to after the opening bracket if possible.
32 - If splitting lines containing expressions, always split BEFORE an operator
33   ("+", "-", "&&" etc.) so that the operator starts the next continuation line.
34 - In split conditional expressions, position the leading "&&" or "||" before
35   its enclosing bracket, so that the following expression aligns after the
36   opening bracket.
38 NAMING
40 - Classes, enums, functions and variable names are in camel case (i.e.
41   separate multiple words by upper-casing each word after the first). Only
42   use underscores for special purposes.
43 - Classes and enum names start with an upper case letter.
44 - Function and variable names start with a lower case letter.
45 - Enum values are either all upper case with words separated by underscores, or
46   camel case starting with an upper case letter.
47 - Constants are all upper case, with words separated by underscores.
48 - Class member variable names start with "m" followed by a upper case letter.
50 EXAMPLE
52 Animal ZooCage::releaseAnimal(const QString& name, Species species,
53                               int arrivalNumber) const
55     if (!name.isEmpty()
56     &&  (arrivalNumber > mMinimumSpeciesCount  &&  arrivalNumber < mMaximumSpeciesCount)
57       || !arrivalNumber)
58     {
59         mLastReleased = Animal(species, name, arrivalNumber);
60         return mAnimals[name][arrivalNumber];
61     }
62     if (name.isEmpty()  ||  mUnclassifiedAnimals.contains(name))
63         return mUnclassifiedAnimalTypes[species];
64     return Animal();