-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathFunNumberOfStatements.qhelp
More file actions
39 lines (34 loc) · 1.29 KB
/
FunNumberOfStatements.qhelp
File metadata and controls
39 lines (34 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>This metric measures the number of statements (including control statements such as
<code>if</code> and <code>while</code>) in each function.
</p>
<p>Functions with many statements are hard to understand and maintain. It is usually a
sign of a function with too many responsibilities.</p>
</overview>
<recommendation>
<p>The primary way to improve the complexity is to extract sub-functionality into separate
functions. If the function naturally breaks up into a sequence of operations it is
preferable to extract each operation as a separate function. This is most likely the case
for large functions with low cyclomatic complexity. Even if the code is straight forward
it is better to extract functionality for readability purposes. Moreover, it may enable
reuse of the extracted subfunctionality.</p>
</recommendation>
<references>
<li>
<a href="http://www.cplusplus.com/doc/tutorial/functions/">Functions</a>
</li>
<li>
M. Fowler. <em>Refactoring</em>. Addison-Wesley, 1999.
</li>
<li>
<a href="https://en.wikipedia.org/wiki/Code_refactoring">Wikipedia: Code refactoring</a>
</li>
<li>
<a href="http://www.jot.fm/issues/issue_2005_01/column1/">Refactoring as Meta Programming?</a>
</li>
</references>
</qhelp>