Software Metrices
Software Metrices
• Software Metrics
• A software metric is a measure of software characteristics which
are measurable or countable. Software metrics are valuable for
many reasons, including measuring software performance,
planning work items, measuring productivity, and many other
uses.
• Within the software development process, many metrics are
that are all connected. Software metrics are similar to the four
functions of management: Planning, Organization, Control, or
Improvement.
Classification of Software Metrics
• Software metrics can be classified into two types as follows:
• 1. Product Metrics: These are the measures of various characteristics
of the software product. The two important software characteristics
are:
1.Size and complexity of software.
2.Quality and reliability of software.
• These metrics can be computed for different stages of SDLC.
• Types of Metrics
• Internal metrics: Internal metrics are the metrics used for measuring
properties that are viewed to be of greater importance to a software
developer. For example, Lines of Code (LOC) measure.
• External metrics: External metrics are the metrics used for measuring
properties that are viewed to be of greater importance to the user,
e.g., portability, reliability, functionality, usability, etc.
• Hybrid metrics: Hybrid metrics are the metrics that combine product,
process, and resource metrics. For example, cost per FP where FP
stands for Function Point Metric.
• Project metrics: Project metrics are the metrics used by the project
manager to check the project's progress. Data from the past projects
are used to collect various metrics, like time and cost; these estimates
are used as a base of new software.
• As the project proceeds, the project manager will check its progress
from time-to-time and will compare the effort, cost, and time with
the original effort, cost and time. Also understand that these metrics
are used to decrease the development costs, time efforts and risks.
• The project quality can also be improved. As quality improves, the
number of errors and time, as well as cost required, is also reduced.
• Advantage of Software Metrics
• Comparative study of various design methodology of software systems.
• For analysis, comparison, and critical study of different programming
language concerning their characteristics.
• In comparing and evaluating the capabilities and productivity of people
involved in software development.
• In the preparation of software quality specifications.
• In the verification of compliance of software systems requirements and
specifications.
• In making inference about the effort to be put in the design and
development of the software systems.
• In getting an idea about the complexity of the code.
• Disadvantage of Software Metrics
• The application of software metrics is not always easy, and in some
cases, it is difficult and costly.
• The verification and justification of software metrics are based on
historical/empirical data whose validity is difficult to verify.
• These are useful for managing software products but not for evaluating
the performance of the technical staff.
• The definition and derivation of Software metrics are usually based on
assuming which are not standardized and may depend upon tools
available and working environment.
• Most of the predictive models rely on estimates of certain variables
which are often not known precisely.
Size Oriented Metrics
• LOC Metrics
• It is one of the earliest and simpler metrics for calculating the size of
the computer program. It is generally used in calculating and
comparing the productivity of programmers. These metrics are
derived by normalizing the quality and productivity measures by
considering the size of the product as a metric.
• Following are the points regarding LOC measures:
1.In size-oriented metrics, LOC is considered to be the normalization value.
2.It is an older method that was developed when FORTRAN and COBOL
programming were very popular.
3.Productivity is defined as KLOC / EFFORT, where effort is measured in person-
months.
4.Size-oriented metrics depend on the programming language used.
5.As productivity depends on KLOC, so assembly language code will have more
productivity.
6.LOC measure requires a level of detail which may not be practically achievable.
7.The more expressive is the programming language, the lower is the productivity.
8.LOC method of measurement does not apply to projects that deal with visual
(GUI-based) programming. As already explained, Graphical User Interfaces
(GUIs) use forms basically. LOC metric is not applicable here.
9.It requires that all organizations must use the same method for counting LOC.
This is so because some organizations use only executable statements, some
useful comments, and some do not. Thus, the standard needs to be established.
10.These metrics are not universally accepted.
Based on the LOC/KLOC count of software, many other metrics can be
computed:
• Errors/KLOC.
• $/ KLOC.
• Defects/KLOC.
• Pages of documentation/KLOC.
• Errors/PM.
• Productivity = KLOC/PM (effort is measured in person-months).
• $/ Page of documentation.
Advantages of LOC
• Simple to measure
Disadvantage of LOC
• It is defined on the code. For example, it cannot measure the size of
the specification.
• It characterizes only one specific view of size, namely length, it takes
no account of functionality or complexity
• Bad software design may cause an excessive line of code
• It is language dependent
• Users cannot easily understand it
Halstead's Software Metrics
• According to Halstead's "A computer program is an implementation of an
algorithm considered to be a collection of tokens which can be classified as
either operators or operand."
• Token Count
• In these metrics, a computer program is considered to be a collection of
tokens, which may be classified as either operators or operands. All
software science metrics can be defined in terms of these basic symbols.
These symbols are called as a token.
• The basic measures are
• n1 = count of unique operators.
• n2 = count of unique operands.
• N1 = count of total occurrences of operators.
• N2 = count of total occurrence of operands.
• In terms of the total tokens used, the size of the program can be
expressed as N = N1 + N2.
Halstead metrics are:
• Program Volume (V)
• The unit of measurement of volume is the standard unit for size
"bits." It is the actual size of a program if a uniform binary encoding
for the vocabulary is used.
• Program Level (L)
• 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).
• Program Difficulty
• The difficulty level or error-proneness (D) of the program is
proportional to the number of the unique operator in the program.
D= (n1/2) * (N2/n2)
• Programming Effort (E)
• The unit of measurement of E is elementary mental discriminations.
E=V/L=D*V
PASCAL 2.54 -
APL 2.42 -
C 0.857 0.445
• Counting rules for C language
1.Comments are not considered.
2.The identifier and function declarations are not considered
3.All the variables and constants are considered operands.
4.Global variables used in different modules of the same program are
counted as multiple occurrences of the same variable.
5.Local variables with the same name in different functions are
counted as unique operands.
6.Functions calls are considered as operators.
7.All looping statements e.g., do {...} while ( ), while ( ) {...}, for ( ) {...},
all control statements e.g., if ( ) {...}, if ( ) {...} else {...}, etc. are
considered as operators.
8.In control construct switch ( ) {case:...}, switch as well as all the case
statements are considered as operators.
9. The reserve words like return, default, continue, break, sizeof, etc., are
considered as operators.
10. All the brackets, commas, and terminators are considered as operators.
11. GOTO is counted as an operator, and the label is counted as an operand.
12. The unary and binary occurrence of "+" and "-" are dealt with separately.
Similarly "*" (multiplication operator) are dealt separately.
13. In the array variables such as "array-name [index]" "array-name" and
"index" are considered as operands and [ ] is considered an operator.
14. In the structure variables such as "struct-name, member-name" or
"struct-name -> member-name," struct-name, member-name are
considered as operands and '.', '->' are taken as operators. Some names
of member elements in different structure variables are counted as
unique operands.
15. All the hash directive is ignored.
Example: Consider the sorting program as shown in fig: List out the
operators and operands and also calculate the value of software
science measure like n, N, V, E, λ ,etc.
Operators Occurrences Operands Occurrences
int 4 SORT 1
() 5 x 7
, 4 n 3
[] 7 i 8
if 2 j 7
< 2 save 3
; 11 im1 3
for 2 2 2
= 6 1 3
- 1 0 1
<= 2 - -
++ 2 - -
return 2 - -
{} 3 - -
n1=14 N1=53 n2=10 N2=38
• Functional Point (FP) Analysis
• Allan J. Albrecht initially developed function Point Analysis in
1979 at IBM and it has been further modified by the
International Function Point Users Group (IFPUG).
• FPA is used to make estimate of the software project, including
its testing in terms of functionality or function size of the
software product.
• Functional point analysis may be used for the test estimation of
the product. The functional size of the product is measured in
terms of the function point, which is a standard of measurement
to measure the software application.
• Objectives of FPA
• The basic and primary purpose of the functional point analysis
is to measure and provide the software application functional
size to the client, customer, and the stakeholder on their
request.
• It is used to measure the software project development along
with its maintenance, consistently throughout the project
irrespective of the tools and the technologies.
• Following are the points regarding FPs
1. FPs of an application is found out by counting the number and
types of functions used in the applications. Various functions used
in an application can be put under five types, as shown in Table:
Measurements Parameters Examples
The functional complexities are multiplied with the corresponding weights against
each function, and the values are added up to determine the UFP (Unadjusted
Function Point) of the subsystem.
Here that weighing factor will be simple, average, or complex for a measurement parameter type.
The Function Point (FP) is thus calculated with the following formula.
and ∑(fi) is the sum of all 14 questionnaires and show the complexity adjustment
value/ factor-CAF (where i ranges from 1 to 14). Usually, a student is provided with the
value of ∑(fi)
Also note that ∑(fi) ranges from 0 to 70, i.e.,
• 0 <= ∑(fi) <=70
• and CAF ranges from 0.65 to 1.35 because
1.When ∑(fi) = 0 then CAF = 0.65
2.When ∑(fi) = 70 then CAF = 0.65 + (0.01 * 70) = 0.65 + 0.7 = 1.35
• Based on the FP measure of software many other metrics can be computed:
1.Errors/FP
2.$/FP.
3.Defects/FP
4.Pages of documentation/FP
5.Errors/PM.
6.Productivity = FP/PM (effort is measured in person-months).
7.$/Page of Documentation.
• 8. LOCs of an application can be estimated from FPs. That is, they are
interconvertible. This process is known as backfiring. For example, 1
FP is equal to about 100 lines of COBOL code.
• 9. FP metrics is used mostly for measuring the size of Management
Information System (MIS) software.
• 10. But the function points obtained above are unadjusted function points
(UFPs). These (UFPs) of a subsystem are further adjusted by
considering some more General System Characteristics (GSCs). It is a
set of 14 GSCs that need to be considered. The procedure for adjusting
UFPs is as follows:
1.Degree of Influence (DI) for each of these 14 GSCs is assessed on a
scale of 0 to 5. (b) If a particular GSC has no influence, then its weight is
taken as 0 and if it has a strong influence then its weight is 5.
2.The score of all 14 GSCs is totaled to determine Total Degree of
Influence (TDI).
3.Then Value Adjustment Factor (VAF) is computed from TDI by using the
formula: VAF = (TDI * 0.01) + 0.65
• The value of VAF lies within 0.65 to 1.35 because
• Where C = Costs
L= size
a and b are constants
• The Software Engineering Laboratory established a model called
SEL model, for estimating its software production.
• This model is an example of the static, single variable model.
• Static, Multivariable Models: These models are based on method
(1), they depend on several variables describing various aspects of
the software development environment.
• In some model, several variables are needed to describe the
software development process, and selected equation combined
these variables to give the estimate of time & cost. These models
are called multivariable models.
WALSTON and FELIX develop the models at IBM provide the following equation
gives a relationship between lines of source code and effort:
Example: Compare the Walston-Felix Model with the SEL model on a software development
expected to involve 8 person-years of effort.
1. Calculate the number of lines of source code that can be produced.
2. Calculate the duration of the development.
3. Calculate the productivity in LOC/PY
4. Calculate the average manning
• The value of the constant a and b are depends on the project type.
In COCOMO, projects are categorized into three types:
1.Organic: A development project can be treated of the organic type, if the project deals with developing a
well-understood application program, the size of the development team is reasonably small, and the team
members are experienced in developing similar methods of projects.
• Examples of this type of projects are simple business systems, simple inventory management systems,
and data processing systems.
2. Semidetached: A development project can be treated with semidetached type if the development
consists of a mixture of experienced and inexperienced staff. Team members may have finite experience in
related systems but may be unfamiliar with some aspects of the order being developed.
• Example of Semidetached system includes developing a new operating system (OS), a Database
Management System (DBMS), and complex inventory management system.
3. Embedded: A development project is treated to be of an embedded type, if the software being
developed is strongly coupled to complex hardware, or if the stringent regulations on the operational
method exist.
• For Example: ATM, Air Traffic control.
For three product categories, Bohem provides a different set of expression to predict effort (in a unit of
person month)and development time from the size of estimation in KLOC(Kilo Line of code) efforts
estimation takes into account the productivity loss due to holidays, weekly off, coffee breaks, etc.
• According to Boehm, software cost estimation should be done through three stages:
• Basic Model
• Intermediate Model
• Detailed Model
1. Basic COCOMO Model: The basic COCOMO model provide an accurate size of the project
parameters. The following expressions give the basic COCOMO estimation model:
K is the total effort expended (in PM) in product development, and L is the product estimate in KLOC .
• Putnam proposed that optimal staff develop on a project should follow the
Rayleigh curve.
• Only a small number of engineers are required at the beginning of a plan to
carry out planning and specification tasks.
• As the project progresses and more detailed work are necessary, the number
of engineers reaches a peak. After implementation and unit testing, the
number of project staff falls.