Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KAlarm
Commits
d67f4cf1
Commit
d67f4cf1
authored
Apr 22, 2012
by
David Jarvie
Browse files
Add coding guidelines
parent
ff6d0140
Changes
1
Hide whitespace changes
Inline
Side-by-side
CODING_STYLE
0 → 100644
View file @
d67f4cf1
KAlarmCal coding style
======================
KAlarmCal code should adhere to the following stylistic rules.
SPACING
- No tabs.
- Indent with 4 spaces.
- No spaces inside round or square brackets.
- No space between a function name and the bracket following.
- Place '*' and '&' immediately after the type in declarations, followed by a
space, e.g. "const QString& from", "char* str".
- Normally two spaces on each side of "&&" and "||" in "if"/"while"/"for"
statements.
- Indent "case" within "switch" statements.
BRACES
- Opening brace on a new line.
- No braces are used when only a single statement follows 'if', 'for' etc.
SPLITTING LINES
- There is in general no need to split lines less than 120 characters. Beyond
that length, it's at the coder's discretion.
- Conditional statements occupying line lengths less than 120 characters may be
split for clarity.
- Long "for" statements should be split before each clause at least.
- If a function call or declaration has to be split over more than one line,
indent to after the opening bracket if possible.
- If splitting lines containing expressions, always split BEFORE an operator
("+", "-", "&&" etc.) so that the operator starts the next continuation line.
- In split conditional expressions, position the leading "&&" or "||" before
its enclosing bracket, so that the following expression aligns after the
opening bracket.
NAMING
- Classes, enums, functions and variable names are in camel case (i.e.
separate multiple words by upper-casing each word after the first). Only
use underscores for special purposes.
- Classes and enum names start with an upper case letter.
- Function and variable names start with a lower case letter.
- Enum values are either all upper case with words separated by underscores, or
camel case starting with an upper case letter.
- Constants are all upper case, with words separated by underscores.
- Class member variable names start with "m" followed by a upper case letter.
EXAMPLE
Animal ZooCage::releaseAnimal(const QString& name, Species species,
int arrivalNumber) const
{
if (!name.isEmpty()
&& (arrivalNumber > mMinimumSpeciesCount && arrivalNumber < mMaximumSpeciesCount)
|| !arrivalNumber)
{
mLastReleased = Animal(species, name, arrivalNumber);
return mAnimals[name][arrivalNumber];
}
if (name.isEmpty() || mUnclassifiedAnimals.contains(name))
return mUnclassifiedAnimalTypes[species];
return Animal();
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment