Difference between revisions of "Cpp Coding Standards/FIMPL"

From Apache OpenOffice Wiki
Jump to: navigation, search
m
Line 1: Line 1:
== Function Implementation ==
+
Topic-Id: '''FIMPL'''
 +
 
 
Issues when implementing function bodies.
 
Issues when implementing function bodies.
 
----
 
----
 
=== Summary ===
 
=== Summary ===
==== ShortFunctions ====
+
==== 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.
  
==== NoMagicNumbers ====
+
[[/Short|Details]]
 +
 
 +
==== No Magic Numbers <span id="MagNum">(MagNum)</span> ====
 
Don't use unnamed constants in your code. Give them a descriptive name.
 
Don't use unnamed constants in your code. Give them a descriptive name.
  
==== SwitchDefault ====
+
[[/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.
 
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.
 
Comment missing breaks.
  
==== NoCatchAll ====
+
[[/DefSwitch|Details]]
 +
 
 +
==== No Catch All <span id="Catch">(Catch)</span> ====
 
Avoid catch(...).
 
Avoid catch(...).
 +
 +
[[/Catch|Details]]
 +
 
----
 
----
 
=== Related Rules ===
 
=== Related Rules ===
* [[../CLSINIT#NoVirt| Class Construction, Destruction and Copying/No Virtual Calls in Constructor or Destructor]]
+
* [[../Class Construction, Destruction and Copying#NoVirt |CLSINIT:NoVirt]] - No Virtual Calls in Constructor or Destructor
* [[../FDESIGN#OneTask | FDESIGN:OneTask]]
+
* [[../Function Design#OneTask | FDESIGN:OneTask]] - One Task
* [[../GEN | GEN]] – all items
+
* [[../General Coding |GEN]] – all items
* [[../OBSOLETE#AvoidHeapAlloc | OBSOLETE:AvoidHeapAlloc]]
+
* [[../Obsolete Habits#AvoidHeapAlloc |OBSOLETE:AvoidHeapAlloc]] - Avoid Allocating on the Heap
* [[../OBSOLETE#NoOldMacros | OBSOLETE:NoOldMacros]]  
+
* [[../Obsolete Habits#NoOldMacros |OBSOLETE:NoOldMacros]] - Avoid Outdated Macros
* [[../STL#UseAlgorithms | STL:UseAlgorithms]]
+
* [[../STL#UseAlgorithms |STL:UseAlgorithms]] - Use the STL Algorithms
----
 
=== Explanations ===
 
  
 
----
 
----
 
[[Category:Coding Standards]]
 
[[Category:Coding Standards]]

Revision as of 14:39, 29 November 2006

Topic-Id: FIMPL

Issues when implementing function bodies.


Summary

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.

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