Difference between revisions of "Cpp Coding Standards/FIMPL"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
m (No Magic Numbers <span id="MagNum">(MagNum)</span>)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
Topic-Id: '''FIMPL'''
+
=== Function Implementation (FIMPL) - Summary ===
 +
''Issues when implementing function bodies.''
  
Issues when implementing function bodies.
+
===== Short Functions <span id="Short">(Short)</span> =====
----
+
=== Summary ===
+
==== Short Functions <span id="Short">(Short)</span> ====
+
 
Make functions short.  
 
Make functions short.  
  
Consider replacing comments by function calls. Consider to flatten deep nested control structures by moving parts of them in extra functions. Consider moving complicated loop bodies into extra functions. Put repeated code snippets in an extra function.
+
Consider replacing comments by function calls. Consider to flatten deep nested control structures by moving parts of them in extra functions. Consider moving complicated loop bodies into extra functions. Put repeated code snippets in an extra function. [[/Short|-> Details]]
 
+
[[/Short|Details]]
+
 
+
==== No Magic Numbers <span id="MagNum">(MagNum)</span> ====
+
Don't use unnamed constants in your code. Give them a descriptive name.
+
 
+
[[/MagNum|Details]]
+
 
+
==== Default in switch Statements <span id="DefSwitch">(DefSwitch)</span> ====
+
Don't just drop out of a switch statement, always provide a default case or a comment, why it is not needed.
+
 
+
Comment missing breaks.
+
  
[[/DefSwitch|Details]]
+
===== No Magic Numbers <span id="MagNum">(MagNum)</span> =====
 +
Don't use unnamed constants in your code. Give them a descriptive name. The definition is prefered in the headers [[/MagNum|-> Details]]
  
==== No Catch All <span id="Catch">(Catch)</span> ====
+
===== Default in switch Statements <span id="DefSwitch">(DefSwitch)</span> =====
Avoid catch(...).
+
Don't just drop out of a switch statement, always provide a default case or a comment, why it is not needed.<br>
 +
Comment missing breaks.<br>
 +
[[/DefSwitch|-> Details]]
  
[[/Catch|Details]]
+
===== No Catch All <span id="Catch">(Catch)</span> =====
 +
Avoid catch(...). [[/Catch|-> Details]]
  
 
----
 
----
 
=== Related Rules ===
 
=== Related Rules ===
* [[../Class Construction, Destruction and Copying#NoVirt |CLSINIT:NoVirt]] - No Virtual Calls in Constructor or Destructor
+
* [[../CLSINIT#NoVirt |CLSINIT:NoVirt]] - No Virtual Calls in Constructor or Destructor
* [[../Function Design#OneTask | FDESIGN:OneTask]] - One Task
+
* [[../FDESIGN#OneTask | FDESIGN:OneTask]] - One Task
* [[../General Coding |GEN]] – all items
+
* [[../GEN|GEN]] – all items
* [[../Obsolete Habits#Stack |OBSOLETE:Stack]] - Prefer Allocation from Stack
+
* [[../OBSOLETE#Stack |OBSOLETE:Stack]] - Prefer Allocation from Stack
* [[../Obsolete Habits#NoMacro |OBSOLETE:NoMacro]] - No Old Macros
+
* [[../OBSOLETE#NoMacro |OBSOLETE:NoMacro]] - No Old Macros
 
* [[../STL#Algo |STL:Algo]] - Prefer the STL Algorithms
 
* [[../STL#Algo |STL:Algo]] - Prefer the STL Algorithms
  
 
----
 
----
 
[[Category:Coding Standards]]
 
[[Category:Coding Standards]]

Latest revision as of 21:33, 30 July 2008

Function Implementation (FIMPL) - Summary

Issues when implementing function bodies.

Short Functions (Short)

Make functions short.

Consider replacing comments by function calls. Consider to flatten deep nested control structures by moving parts of them in extra functions. Consider moving complicated loop bodies into extra functions. Put repeated code snippets in an extra function. -> Details

No Magic Numbers (MagNum)

Don't use unnamed constants in your code. Give them a descriptive name. The definition is prefered in the headers -> Details

Default in switch Statements (DefSwitch)

Don't just drop out of a switch statement, always provide a default case or a comment, why it is not needed.
Comment missing breaks.
-> Details

No Catch All (Catch)

Avoid catch(...). -> Details


Related Rules


Personal tools