-
-
Notifications
You must be signed in to change notification settings - Fork 164
CodingStyle
Alexander Barthel edited this page Nov 17, 2018
·
2 revisions
If you're in Rome do it like the Romans.
You can use the included uncrustify.cfg and Uncrustify to format the code. Avoid formatting whole files since this can result in merge conflicts.
- Do not use Hungarian Notation.
- Do not prefix class variables with underscore
_
. - Class, struct and enum names in camel case with first letter upper case:
MapProcedureLegs
. No underscores. - Variable and parameter names in camel case with first letter lower case:
currentDistanceMarkerIndex
. No underscores. - Constants and enum values all upper case with underscores:
MAX_SIM_UPDATE_TOOLTIP_MS
. - Use
get
andset
prefixes for simple setters and getters. - File names shall correspond to class names if applicable. Use only lower case,
.h
and*.cpp
file endings. - Sub directories in source tree all lower case.
- Mind the case in includes. This has to compile on Linux too.
- Always use const references when passing bigger structures to methods. Do this also for the inherently shared classes like
QString
.
- Use
QString
and other Qt container classes instead ofstd::string
orstd::vector
. - Do not use the old
SIGNAL
andSLOT
macros. These are not type safe:QObject::connect(&a, SIGNAL(valueChanged(int)), &b, SLOT(setValue(int)));
. Use the new methods instead:QObject::connect(&a, &Counter::valueChanged, &b, &Counter::setValue);