| Home | |
![]() |
Source Files |
| Prev | Coding Rules | Next |
The following rules apply to all source code files.
C++ source files shall end with the extension .cpp not .cc or .cxx
As with header files these should start with a header block similar to the one generated by KDevelop.
Include files shall be included in the same format as for header file e.g
Example 3.7. Including header files in source files
//----------------------------------------------------------------------- // QT Headers #include <qtlabel.h> //----------------------------------------------------------------------- // KDE Headers #include <kcombobox.h> //----------------------------------------------------------------------- // Project Headers #include "mymoney/mymoneyfile.h" #include "ksomethingdlg.h"
Methods should be implemented as such:
Example 3.8. Method implementation
void KSomethingDlg::useString(void)
{
.. function body
}
with the function body indented by one tab (equals two spaces).
Flow control statements should preferably follow the Kernighan & Ritchie style as such:
Example 3.9. Kernighan & Ritchie flow control style
while (something_is_true) {
operate on something;
}
although the following Allman style is acceptable:
Example 3.10. Allman flow control style
while (something_is_true)
{
operate on something;
}
It is also acceptable for one line body statements to omit the curly braces as such:
Example 3.11. One line body flow control style
while (something_is_true)
operate;
Local variables should not be prefixed by the m_ member prefix and should start with a prefix as discussed for the header file. For example:
Example 3.12. Local variable nameing convention
QString qstringTemp; char *pszTemp;
Each method should have a comment block preceeding it in a suitable format for other developers to see how the method works and what types of return and arguments it expects. It does not have to be kdoc compatable because kdoc only parses the header files. All kdoc comment blocks should be in the header files.
| Prev | Home | Next |
| Header Files | Up | Creating dialog boxes in KMyMoney |