Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
dev:coding_style [2010/12/17 01:27]
michael
dev:coding_style [2013/07/21 11:44]
tedfelix [Comments] Add info about doxygen issue
Line 4: Line 4:
 Rosegarden house style is as follows, in approximately descending order of importance: Rosegarden house style is as follows, in approximately descending order of importance:
  
-  * Class names are UpperCamelCase, method names are lowerCamelCase, non-public member variables are m_prefixedCamelCase, slot names start with "slot".+===== Names =====
  
-  * Indentation is by four spaces at a time.  There should be **no tab characters anywhere** in Rosegarden source code.  The indentation should look the same regardless of whether you read it in an IDEin a terminal window with "cat" or "vi"in Emacsor quoted in an email. It **must not** depend on having the right settings for tab-to-space conversion in your IDE when you read it.  (Emacs and vim users will note that we already start every source file with a meta-comment that sets up the right indentation mode in these editors.)+Class names are UpperCamelCasemethod names are lowerCamelCasenon-public member variables are m_prefixedCamelCaseslot names start with "slot".
  
-  * Use [[dev:doxygen|doxygen-style]] comments for class and function documentation <code>/** ... */</code> or <code>///</code>+===== Indentation =====
  
-  * No extra indentation inside namespaces; set off inner code by two carriage returns on either side of namespace brackets+Indentation is by four spaces at a time.  There should be **no tab characters anywhere** in Rosegarden source code.  The indentation should look the same regardless of whether you read it in an IDE, in a terminal window with "cat" or "vi", in Emacs, or quoted in an email. It **must not** depend on having the right settings for tab-to-space conversion in your IDE when you read it.  (Emacs and vim users will note that we already start every source file with a meta-comment that sets up the right indentation mode in these editors.) 
 + 
 +===== Namespaces ===== 
 + 
 +No extra indentation inside namespaces; set off inner code by two carriage returns on either side of namespace brackets
  
 <code c++> <code c++>
Line 26: Line 30:
 </code> </code>
  
-  * Braces are what you might call Java-style, which means:+===== Braces ===== 
 + 
 +Braces are what you might call Java-style, which means:
  
 <code c++> <code c++>
Line 44: Line 50:
 </code> </code>
  
-  * Single statement blocks are preferably either "inline" or bracketed.  Like this:+===== if ===== 
 + 
 +Single statement blocks are preferably either "inline" or bracketed.  Like this: 
 <code c++> <code c++>
    if (something) somethingElse();    if (something) somethingElse();
Line 62: Line 71:
 </code> </code>
  
-  * Whitespace is much as in the above examples (outside but not inside ''()'', after but not before '';'', etc.):+===== Parentheses and Whitespace ===== 
 + 
 +Whitespace is much as in the above examples (outside but not inside ''()'', after but not before '';'', etc.):
 <code c++> <code c++>
     connect(detailsButton, SIGNAL(clicked(bool)), this, SLOT(slotDetails()));     connect(detailsButton, SIGNAL(clicked(bool)), this, SLOT(slotDetails()));
Line 82: Line 93:
 No whitespace between ''if'' (and other C++ keywords) and the ''('' makes Michael's eyes hurt. No whitespace between ''if'' (and other C++ keywords) and the ''('' makes Michael's eyes hurt.
  
-  * Pointers are ''MyObject *ptr;'' not ''MyObject* ptr;''+===== Pointers ===== 
 + 
 +Pointers are ''MyObject *ptr;'' not ''MyObject* ptr;'' 
 + 
 +===== Argument Alignment =====
  
   * If you have more arguments than will fit on a reasonable length line (80 characters is a good figure, but this is not a hard rule), align the extra arguments below and just after the opening ( rather than at a new level of indentation:   * If you have more arguments than will fit on a reasonable length line (80 characters is a good figure, but this is not a hard rule), align the extra arguments below and just after the opening ( rather than at a new level of indentation:
Line 109: Line 124:
 </code> </code>
                                                          
 +===== Comments =====
 +
 +  * Use [[dev:doxygen|doxygen-style]] comments for class and function documentation <code>/** ... */</code> or <code>///</code>
  
   * Use comment codes in your comments when appropriate:   * Use comment codes in your comments when appropriate:
Line 119: Line 137:
 | <code>//$$$</code>    | Strings to change after a freeze ends | | <code>//$$$</code>    | Strings to change after a freeze ends |
  
 +//Note: %%//!!!%% causes problems for doxygen.  We might want to revise the above.  Adding a space avoids problems: %%// !!!%%//
  
   * If in doubt, please err on the side of putting in too many comments.  We have contributors of all ability levels working here, and what may seem obvious to you might be complete gibberish to someone else.  Comments give everyone a better chance to be useful, and they are always welcome, while nobody will think you are a super code warrior or code gazelle for committing a thousand lines that have only three choice comments   * If in doubt, please err on the side of putting in too many comments.  We have contributors of all ability levels working here, and what may seem obvious to you might be complete gibberish to someone else.  Comments give everyone a better chance to be useful, and they are always welcome, while nobody will think you are a super code warrior or code gazelle for committing a thousand lines that have only three choice comments
Line 142: Line 161:
 (The reason C++-style comments are preferred is not arbitrary.  C++-style comments are much more obvious when viewing diffs on the rosegarden-bugs list, because they force the entire block of text to be displayed, instead of only the starting and ending lines.) (The reason C++-style comments are preferred is not arbitrary.  C++-style comments are much more obvious when viewing diffs on the rosegarden-bugs list, because they force the entire block of text to be displayed, instead of only the starting and ending lines.)
  
-  * Includes should try to follow the following pattern:+===== #include Order ===== 
 + 
 +Includes should try to follow the following pattern: 
 <code> <code>
 #include "MyHeader.h" #include "MyHeader.h"
Line 159: Line 181:
 </code> </code>
  
-  * Switch statements are all over the place, and we need to pick one style and use it, so we'll call this a good switch statement:+===== Switch ===== 
 + 
 +Switch statements are all over the place, and we need to pick one style and use it, so we'll call this a good switch statement:
 <code c++> <code c++>
     switch (hfix) {     switch (hfix) {
Line 207: Line 231:
     }     }
 </code> </code>
 +
 +===== Varables =====
  
   * You should feel encouraged to use variables to make the code easier to understand without a look at the header or the API docs.  Good:   * You should feel encouraged to use variables to make the code easier to understand without a look at the header or the API docs.  Good:
Line 250: Line 276:
     }     }
 </code> </code>
 +
 +===== Menu Items =====
 +
 +Menu items use [[http://en.wikipedia.org/wiki/Capitalization#Titles|title case]].  We don't capitalize pronouns except pronouns "standing alone" (exhaustive pronouns).  For instance, "Move to Staff Above".
 +
 +We use trailing dots "..." to indicate that a menu item leads to a dialog.
 +
 +For example:
 +
 +<code>
 +    <Action name="general_move_events_up_staff" 
 +     text="&amp;Move to Staff Above..." />
 +</code>
 +
  
 ===== See also: ===== ===== See also: =====
   * [[layout_code|Qt Layouts]]   * [[layout_code|Qt Layouts]]
   * [[[config_groups]Config Groups]]   * [[[config_groups]Config Groups]]
- 
 
 
dev/coding_style.txt · Last modified: 2022/05/06 16:07 (external edit)
Recent changes RSS feed Creative Commons License Valid XHTML 1.0 Valid CSS Driven by DokuWiki