-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathStatementNestingDepth.qhelp
More file actions
33 lines (27 loc) · 1.09 KB
/
StatementNestingDepth.qhelp
File metadata and controls
33 lines (27 loc) · 1.09 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
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>This metric measures the maximum nesting depth of statements. When statements are nested too
deeply in the code they become difficult to understand. This is because understanding a line that
is deeply nested requires an understanding of the context of that line.</p>
</overview>
<recommendation>
<p>The best way to address this problem is to extract more deeply nested parts of the code into their own logical
methods.</p>
</recommendation>
<example>
<p>This method has a nesting depth of 4.</p>
<sample src="StatementNestingDepth.cs" />
</example>
<section title="Fixed by Extraction">
<p>This code is easier to read because the part that prints every character in the string along
with its character code has been extracted to a separate method.</p>
<sample src="StatementNestingDepthFix.cs" />
</section>
<references>
<li>Martin Fowler. <em>Refactoring</em>. pp. 89-95. Addison-Wesley. 1999.</li>
<li>Steve McConnell - <em>Code Complete: A Practical Handbook of Software Construction</em>.</li>
</references>
</qhelp>