Warning, /network/kget/HACKING is written in an unsupported language. File is not indexed.
0001 This file has been copied from the kicker HACKING file from Aaron Seigo. 0002 0003 While you may notice that there are many discrepencies between 0004 the code and this document, all new development should 0005 follow the coding style as described below amd one day the codebase will 0006 actually be consistent! 0007 0008 Naming Conventions 0009 ------------------ 0010 Class names start with a capital letter, member variables begin with m_. 0011 Methods and functions start with a lower case letter. 0012 0013 0014 Indenting 0015 --------- 0016 Tabstop is 4 spaces. No tabs, only spaces. 0017 0018 Try to keep lines under 80 characters in width. When wrapping a single 0019 logical line of code across multiple lines, new lines should be indented 0020 at least once and should preferably line up with parentheses, if any, on 0021 the line above. e.g.: 0022 0023 someMethod(parameterOne, parameterTwo, 0024 parameterThree, parameterFour); 0025 0026 If a boolean expression is spread out over several lines, the boolean 0027 operator is always the last item on the line, e.g.: 0028 0029 if ((condition1 || condition2) && 0030 condition3 && 0031 (condition4 || condition5)) 0032 { 0033 0034 Switch statements should have the case line indented and the case block 0035 itsel further indented, e.g.: 0036 0037 switch (condition) 0038 { 0039 case 1: 0040 ... 0041 break; 0042 case 2: 0043 ... 0044 break; 0045 default: 0046 ...; 0047 } 0048 0049 Spaces 0050 ------ 0051 A single space should appear between keywords and parentheses, eg: 0052 0053 if ( 0054 while ( 0055 for ( 0056 0057 No spaces appear between function/method names and parentheses: 0058 0059 function( 0060 someObject->method( 0061 0062 No spaces appear between opening closing parens and the arguments: 0063 0064 for (int i = 0; i < count; ++i) 0065 0066 Spaces appear between operators, e.g.: 0067 0068 int i = i + 3; 0069 someObject.setValue(someObject.currentValue() + 1) 0070 0071 0072 Braces 0073 ------ 0074 Braces always appear on a line by themself, indented to align with the 0075 above keyword: 0076 0077 if (foo) 0078 { 0079 ... 0080 } 0081 else 0082 { 0083 ... 0084 } 0085 0086 Unless it uglifies the code, use braces even for one-liner conditionals: 0087 0088 if (foo) 0089 { 0090 return 1; 0091 } 0092 0093 Always use braces if the conditional expression wraps across multiple 0094 physical lines. 0095 0096 Braces around case blocks in switch statements are optional. 0097 0098 0099 Constructors 0100 ------------ 0101 Constructors are written as: 0102 0103 MyClass::MyClass(...) 0104 : SuperClass(...), 0105 m_member1(...), 0106 m_member2(...), 0107 ... 0108 { 0109 0110 0111 Class Definitions 0112 ----------------- 0113 Class definitions will follow the following order: 0114 0115 class <name> : <scope> <superclass> 0116 { 0117 public: 0118 <ctors> 0119 <dtors> 0120 <operators> 0121 <other methods> 0122 0123 <members> 0124 0125 public slots: 0126 <methods> 0127 0128 signals: 0129 <methods> 0130 0131 protected: 0132 <ctors> 0133 <dtors> 0134 <operators> 0135 0136 <members> 0137 0138 protected slots: 0139 <methods> 0140 0141 private: 0142 <ctors> 0143 <dtors> 0144 <operators> 0145 0146 <members> 0147 0148 private slots: 0149 <methods> 0150 };