Editing Miniature/Policies

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 65: Line 65:
* Use const refs for arguments when possible, even if the type is COW (copy-on-write, for example QString).
* Use const refs for arguments when possible, even if the type is COW (copy-on-write, for example QString).
-
 
-
* Conditionals
 
-
** One line before and after conditional blocks, to visually separate it from the surrounding code.
 
-
** It is OK for single-line conditional blocks to omit the braces (because of the extra newlines).
 
-
** && and || belong on the next line, if the condition needs to be wrapped (indented by 4 spaces). Put braces around complex conditions, to logically group them together (and to prevent operator precendence bugs, too):
 
-
 
-
  if ((something && somethingElse)
 
-
      || orPerhapsThis)
 
-
      ...
 
-
 
-
** Details:
 
-
*** Conditionals often contain bugs. Especially when the surrounding code gets refactored, those bugs simply slip in.
 
-
*** If a conditional needs to be wrapped, it starts to look ugly. Good! It might lead you to refactor the code, moving the condition itself into a predicate function (which has the nice effect to serve as a comment, if it has a good name).
 
-
*** Nested conditionals quickly start to look ugly with all those line separators, but you probably guessed it already: It's just another sign that this code might need some cleanup! Nested conditionals should be used rarely or hidden within dedicated methods.
 
-
 
-
* One space after keywords that could be mistaken as functions (if, for, ...).
 
* If you store a pointer to an object over which you do not intend to take ownership, then wrap this pointer in a QPointer:
* If you store a pointer to an object over which you do not intend to take ownership, then wrap this pointer in a QPointer:

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)