Warning, /education/marble/CODING is written in an unsupported language. File is not indexed.
0001 Coding Standards for Marble
0002 ===========================
0003
0004
0005 This file contains the coding standards for Marble. If you want to
0006 add or change code in Marble, you must follow these standards.
0007
0008
0009 Foundation
0010 ----------
0011
0012 The foundation for these standards is the kdelibs coding style. It is
0013 described here: https://community.kde.org/Policies/Kdelibs_Coding_Style
0014 I suggest that you start by reading that document, it's not long.
0015
0016
0017 Recapitulation
0018 --------------
0019
0020 Let's recapitulate a few key points from the kdelibs coding
0021 style. This is not the full standard, but just the most important
0022 points.
0023
0024 - 4 spaces indentation
0025 - no tabs in the source code
0026 - opening braces at end of line (except struct, class, functions and
0027 namespaces)
0028 - as little abbreviation in variable names as possible
0029 - one variable declaration per line
0030 - whitespace after control statements
0031 - no space after pointer or reference ('*foo', not '* foo')
0032 - no lines longer than 100 chars.
0033
0034 That's a very short recapitulation of the above mentioned document.
0035 The full document contains lots of examples to show how it should be
0036 done.
0037
0038 Class names and Variables
0039 -------------------------
0040
0041 - Class names should have the ("namespace") prefix "Marble" if
0042
0043 * they are parts of the Marble library that get exported.
0044 * they resemble widgets or similar visually exposed items
0045
0046 The remaining part of the name should reflect the purpose of the
0047 class and should be camel cased with the first letter being upper
0048 cased.
0049
0050 All other classes should not have the "Marble" prefix.
0051
0052 - All header files should contain an include guard which prevents from
0053 including a header file more than once. The include guard name consists
0054 of the Marble namespace prefix (if the class is part of the Marble
0055 namespace), the name of the class and an H. The name is in full upper case
0056 and separated with an underscore.
0057
0058 Correct:
0059 #ifndef MARBLE_ROUTINGWIDGET_H
0060 #define MARBLE_ROUTINGWIDGET_H
0061 ...
0062 #endif // MARBLE_ROUTINGWIDGET_H
0063
0064 Wrong:
0065 MARBLE_ROUTING_WIDGET_H
0066 MARBLEROUTINGWIDGET_H
0067 ROUTINGWIDGET_H
0068 ROUTING_WIDGET_H
0069
0070 - camelCasing with the first letter being lower cased should be used
0071 for methods and variables (e.g. myMethodName()). Full
0072 upper cased names should be used for constants (e.g. RAD2DEG).
0073
0074 Extensions
0075 ----------
0076
0077 The style defined above is not complete, so we have added the
0078 following item:
0079
0080
0081 Broken Lines in Expressions
0082 - - - - - - - - - - - - - -
0083
0084 If an expression is so long that the line has to be broken, the break
0085 should occur *in front of* an operator, not *behind* it.
0086
0087 Example:
0088
0089 var = very_long_sub_expression
0090 + another_very_long_sub_expression;
0091
0092 Another common case for this is logical expressions for if statements:
0093
0094 if (very_long_sub_expression
0095 && another_very_long_sub_expression) {
0096 doSomething();
0097 }
0098
0099 See also below for how to handle braces in this case.
0100
0101
0102 Special considerations for Marble
0103 ---------------------------------
0104
0105 Some things are only applicable for Marble.
0106
0107 Abbreviations
0108 - - - - - - -
0109
0110 Use the following abbreviations in variable names and comments:
0111
0112 lon longitude (not lng!)
0113 lat latitude
0114
0115 As parameters (and preferably in other places as well)
0116 longitude and latitude should appear in lon-lat order
0117 (not lat-lon!).
0118
0119
0120 Dependencies
0121 ------------
0122
0123 Marble has a policy to be buildable using only recent versions of Qt and cmake.
0124 I.e. to compile Marble with its basic functionality (library or app) no other dependencies are required.
0125
0126 However, certain features may only be enabled if additional optional dependencies are available.