Warning, /office/calligra/sheets/doc/CodingStyle.dox is written in an unsupported language. File is not indexed.
0001 /** 0002 \page coding Coding Style 0003 \author Ariya Hidayat (<a href="mailto:ariya@kde.org">ariya@kde.org</a>) 0004 \author Stefan Nikolaus (<a href="mailto:stefan.nikolaus@kdemail.new">stefan.nikolaus@kdemail.net</a>) 0005 \date 2008-08-24 0006 0007 \par Status: 0008 FINISHED 0009 0010 Calligra Sheets follows the 0011 <a href="http://techbase.kde.org/Policies/Kdelibs_Coding_Style">KDElibs Coding Style</a>. 0012 \par Example (for details see the link above): 0013 \code 0014 class Foo 0015 { 0016 public: 0017 void doSomething(); 0018 0019 private: 0020 QString *m_name; 0021 }; 0022 0023 void Foo::doSomething() 0024 { 0025 if (!m_name) { 0026 return; 0027 } 0028 0029 for (int i = 0; i < 10; ++i) { 0030 qDebug("%i", i); 0031 } 0032 0033 switch (myEnum) { 0034 case Value1: 0035 doSomething(); 0036 break; 0037 case Value2: 0038 doSomethingElse(); 0039 // fall through 0040 default: 0041 defaultHandling(); 0042 break; 0043 } 0044 } 0045 \endcode 0046 0047 <p>Write <b>clean code</b>. To be correct is better than to be fast. 0048 Calligra Sheets source code is known to grow very fast in its early days and but later 0049 on also more difficult to understand.</p> 0050 0051 <p>Put comment as documentation for classes and member functions. There is still 0052 lack of documentation as for now, whoever understands something about the 0053 classes and functions should write the documentation.</p> 0054 0055 <p>In complex source files, list of header includes can be very long. Unless 0056 there is special reason not do it, try to group them together, i.e. standard 0057 C/C++ headers come first, followed by Qt headers, and then KDE headers, 0058 Calligra core/UI headers and application specific headers. For each group, 0059 sort the header files alphabetically. </p> 0060 0061 <p>Write test cases. This will ease further maintenance. See also the section on Test 0062 Framework above.</p> 0063 0064 <p>Use <a href="http://techbase.kde.org/Policies/Library_Code_Policy#D-Pointers">d-pointer</a> trick (also known pimpl) whenever possible. Such practice will help when later on 0065 we want to expose the API and need to maintain binary compatibility. But the 0066 most important thing is to separate the interface and the implementation. 0067 Furthermore, build time is reduced since modifications on the implementation 0068 would not cause tons of recompile.</p> 0069 0070 0071 \section classes Class Naming 0072 <p>When creating a new class, use the namespace KSpread instead of the KSpread prefix. 0073 Example: use <tt>KSpread::FooBar</tt> instead of <tt>KSpreadFooBar</tt>.</p> 0074 0075 <p>Do not use the term <i>table</i>. It was incorrectly invented quite likely 0076 because of the term <i>Tabelle</i> (German, literally means table). The correct 0077 term is <i>sheet</i> or <i>worksheet</i>. The English version of Microsoft 0078 uses <i>sheet</i> while the German version uses <i>Tabelle</i>.</p> 0079 \subsection classes-dos Dos: 0080 \li <kbd>Sheet</kbd> 0081 \li <kbd>KSpread::FooBar</kbd> 0082 0083 \subsection classes-donts Donts: 0084 \li <kbd style="text-decoration: line-through;">Table</kbd> (use <kbd>Sheet</kbd>) 0085 \li <kbd style="text-decoration: line-through;">KSpreadFooBar</kbd> (use <kbd>KSpread::FooBar</kbd>) 0086 0087 0088 \section filenames File Names 0089 <p>Source file names should not contain the kspread prefix anymore, 0090 but CamelCase form and .cpp extension, i.e. 0091 <tt>FooBar.h</tt> and <tt>FooBar.cpp</tt> (but not <tt>kspread_foo_bar.h</tt> or 0092 <tt>kspread_foo_bar.cc</tt>) for the above example.</p> 0093 \subsection filenames-dos Dos: 0094 \li <kbd>FooBar.cpp</kbd> 0095 \li <kbd>FooBar.h</kbd> 0096 0097 \subsection filenames-donts Donts: 0098 \li <kbd style="text-decoration: line-through;">kspread_foo_bar.cpp</kbd> (use <kbd>FooBar.cpp</kbd>) 0099 \li <kbd style="text-decoration: line-through;">kspread_foo_bar.cc</kbd> (use <kbd>FooBar.cpp</kbd>) 0100 \li <kbd style="text-decoration: line-through;">kspread_foo_bar.h</kbd> (use <kbd>FooBar.h</kbd>) 0101 0102 0103 \section astyle Automatic Source Code Formatting 0104 Use <tt>astyle</tt> for auto-formatting the source code: 0105 \code 0106 astyle --indent=spaces=4 --brackets=linux --indent-labels --pad=oper --unpad=paren 0107 --one-line=keep-statements --convert-tabs --indent-preprocessor 0108 \endcode 0109 */