-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathTNumberOfStatements.qhelp
More file actions
63 lines (50 loc) · 1.58 KB
/
TNumberOfStatements.qhelp
File metadata and controls
63 lines (50 loc) · 1.58 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>
This metric measures the number of statements that occur in a type.
</p>
<p>
If there are too many statements in a type, it is generally
for one of two reasons:
</p>
<ul>
<li>
One or more individual methods of the type contain too many statements, making
them hard to understand, difficult to check and a common source of defects
(particularly towards the end of the methods, since few people ever read that
far). These methods typically lack cohesion because they are trying to do too many things.
</li>
<li>
The type contains too many methods, which generally indicates that it is
trying to do too much, either at the interface or implementation level or
both. It can be difficult for readers to understand because there is a
confusing list of operations.
</li>
</ul>
</overview>
<recommendation>
<p>
As described above, types reported as violations by this rule contain one
or more methods with too many statements, or the type itself contains
too many methods. </p>
<ul>
<li>
Individual methods of the type that contain too many statements should be refactored into multiple, smaller methods. As a rough
guide, methods should be able to fit on a single screen or side of A4. Anything
longer than that increases the risk of introducing new defects during routine code changes.
</li>
<li>
Types that contain too many methods often lack cohesion and are
prime candidates for refactoring.
</li>
</ul>
</recommendation>
<references>
<li>
M. Fowler. <em>Refactoring</em>. Addison-Wesley, 1999.
</li>
</references>
</qhelp>