Measuring Internal Product Attributes: Software Size
Measuring Internal Product Attributes: Software Size
Measuring Internal Product Attributes: Software Size
Chapter 5:
Measuring Internal
Product Attributes:
Software Size
compiled by Samuel Ashagrre
SOFTWARE METRICS 1
Contents
► Software size
► Size: Length (code, specification, design)
► Size: Reuse
► Size: Functionality (function point, feature
point, object point, use-case point)
► Size: Complexity
Software Size
7
4
Software Size
■ Internal product attributes describe a software
product in a way that is dependent only on the
product itself.
■ One of the most useful attributes is the size of a
sofware product, which can be measured statically,
i.e., without executing the system.
■ Size measurement must reflect effort, cost and
productivity.
Software Size: Length
LINES Size
0..9999 Small
10,000..49,999 Medium
50,000..99,999 Semi-large
100,000..499,999 Large
■ Disadvantage of LOC
■ Vague definition
■ Language dependability
■ Not available for early planning
■ Developers’ skill dependability
Length: Code - LOC (cont.)
Disadvantage of LOC
• According to the Computer History Museum Apple Developer
Bill Atkinson in 1982 found problems with this practice:
• When the Lisa team was pushing to finalize their software in
1982, project managers started requiring programmers to
submit weekly forms reporting on the number of lines of code
they had written. Bill Atkinson thought that was silly. For the
week in which he had rewritten QuickDraw’s region
calculation routines to be six times faster and 2000 lines
shorter, he put “-2000″ on the form. After a few more weeks
the managers stopped asking him to fill out the form, and he
gladly complied
Length: Halstead’s Work
programming language
(language constructs) a, b, x
if ... else + - >
100
= main()
goto
Halstead's Software Science
16
Halstead's Software Science
17
Halstead's Software Science
18
Halstead's Software Science
The value of L ranges between zero and one, with L=1 representing a program
written at the highest possible level (i.e., with minimum size).
And estimated program level is L^ =2 * (n2) / (n1)(N2)
19
Halstead's Software Science
– program difficulty
This parameter shows how difficult to handle the
program is.
As the volume of the implementation of a program
increases, the program level decreases and the
difficulty increases.
Thus, programming practices such as redundant
usage of operands, or the failure to use higher-
level control constructs will tend to increase the
volume as well as the difficulty.
20
Halstead's Software Science
21
Halstead's Software Science
22
Halstead's Software Science
23
Halstead's Software Science
– Programming Time – Shows time (in minutes)
needed to translate the existing algorithm into
implementation in the specified program language.
T = E / (f * S)
The concept of the processing rate of the human brain, developed
by the psychologist John Stroud, is also used. Stoud defined a
moment as the time required by the human brain requires to
carry out the most elementary decision. The Stoud number S is
therefore Stoud’s moments per second with:
5 <= S <= 20. Halstead uses 18. The value of S has been
empirically developed from psychological reasoning, and its
recommended value for programming applications is 18.
• Stroud number S = 18 moments / second
• seconds-to-minutes factor f = 60
24
Length: Halstead’s Work /2
The basic metrics for these tokens are the following
I=V/D
Program estimated length
{
int i, j, save, im1;
/*This function sorts array x in ascending order */
If (n< 2) return 1;
for (i=2; i< =n; i++)
{
im1=i-1;
for (j=1; j< =im1; j++)
if (x[i] < x[j])
{
Save = x[i];
x[i] = x[j];
x[j] = save;
}
}
return 0;
}
List out the operators and operands and also calculate
the values of software science measures like
List out the operators and operands and also calculate
the values of software science measures like
Result:
μ1 = 14
N1 = 53
μ2=10
N2=38
Result:
Therefore, N = 91
μ = 24
V = 417.23 bits
N^ = 86.51
V* = 11.6
L = 0.027
D = 37.03
T = 610 seconds
Exercise
boolean sort (int x[ ], int n)
{
int i, j, save, im1;
/*This function sorts array x in ascending order */
If (n< 2) return true;
for (i=2; i< =n; i++)
{
im1=i-1;
for (j=1; j< =im1; j++)
if (x[i] < x[j])
{
Save = x[i];
x[i] = x[j];
x[j] = save;
}
}
return false;
}
Critics of Halstead’s work
Developed in the context of assembly languages and too
fine grained for modern programming languages.
The treatment of basic and derived measures is
somehow confusing.
The notions of time to develop and remaining bugs are
arguable.
Unable to be extended to include the size for
specification and design.
•It depends on usage of operator and operands in
completed code.
•It has no use in predicting complexity of program
at design level.
Advantages of Halstead
Advantages of Halstead :
•Do not require in-depth and control flow analysis
of program.
•Predicts Effort, rate of error and time.
•Useful in scheduling projects.
45
Length: Alternative Methods
Alternative methods for text-based measurement of
code length:
1) Source memory size: Measuring length in terms of
number of bytes of computer storage required for the
program text. Excludes library code.
2) Char size: Measuring length in terms of number
of characters (CHAR) in program text.
3) Object memory size: Measuring length in terms of an
object (executable or binary) file. Includes library code.
All are relatively easy to measure (or estimate).
Length: Code - Problems /1
One of the problems with text-based definition of length
is that the line of code measurement is increasingly less
meaningful as software development turns to more
automated tools, such as:
Tools that generate code from specifications
Visual programming tools
Code Length in OOP
48
Code Length in OOP
49
Importance of Reuse in Size
50
NASA/Goddard's Software Engineering Laboratory
◦ Reused verbatim: the code in the unit which was
reused without any changes.
◦Slightly modified: fewer that 25% of the lines of code
in the unit were modified.
◦ Extensively modified: 25% or more of the lines of
code were modified.
◦ New: none of the code comes from a previously
constructed unit.
51
NASA/Goddard's Software Engineering Laboratory
52
Hewlett-Packard considers three levels of code:
◦new code, reused code, and leveraged code.
53
Measuring Software Size:
Function Point (FP),
Feature Point,
Object Point and
Use-case Point
Function-Oriented Metrics
Function Point (FP) is a weighted measure of
software functionality.
The idea is that a product with more functionality will
be larger in size.
Function-oriented metrics are indirect measures of
software which focus on functionality and utility.
The first function-oriented metrics was proposed by
Albrecht (1979~1983) who suggested a productivity
measurement approach called the Function Point (FP) method.
Function points (FPs) measure the amount of functionality
in a system based upon the system specification.
Estimation before implementation!
Functionality
56
Function Points(FP) can be used to size software
applications accurately
59
Calculating Function Points
Determine the number of components (EI, EO, EQ, ILF, and ELF)
62
63
64
65
66
67
68
Calculating FP (2)
69
Calculating FP (3)
70
Components of TCF
71
Components of TCF
72
73
74
75
76
77
78
79
80
81
82
Calculating FP (2)
83
Example
84
Example
85
Example
86
Example
87
88
89
90
91
FP: Advantages - Summary
105
Space Complexity
◦ Its the amount of memory space required by the algorithm, during
the course of its execution.
◦ An algorithm generally requires space for following components :
◦ Instruction Space : Its the space required to store the executable
version of the program. This space is fixed, but varies depending
upon the number of lines of code in the program.
◦ Data Space : Its the space required to store all the constants and
variables value.
◦ Environment Space : Its the space required to store the
environment information needed to resume the suspended
function.
106
To compare the efficiency of algorithms, a measure of
the degree of difficulty of an algorithm called
computational complexity.
Computational complexity indicates how much effort
is needed to execute an algorithm, or what its cost is.
This cost can be expressed in terms of execution time
(time efficiency, the most common factor) or memory
(space efficiency).
107