Internal Product Attribute
Measurement: Size
        Aspect of Software Size
• Each product development described in size.
• Measuring the size of the software product
  should be straight forward, simple , consistent
  with measurement theory principles.
• Different attribute capture software size:
  – Length-size of product
  – Functionality-measure the functions supplied by
    the product to the user
  – Complexity-interpreted in different way on user
    perspective
     • Problem complexity - computational complexity
     • Algorithmic complexity - complexity of the algorithm
     • Structural complexity - measure the structure of the
       software used to implement
     • Cognitive complexity - measure the effort required to
       understand the software
                 1. Length
• Specification , design and code are three
  major development product whose size are
  known
• Measuring the length of specification predict
  the design and code length.
• Length of early product may indicate the
  effort needed for production of later.
Code
• Use procedural language to produce code
• OO methods , visual programming make
  traditional measurement difficult.
• Two important aspects of measuring the size
  of the code.
1.Traditional code measures – LOC
2.External code- count the number of object
      Traditional code measure
• Measuring the LOC
• Count of all lines except blank lines and
  comments.
• Count of all statements except comments
  (statements taking more than one line count as
  only one line).
• Count of all lines except blank lines,
  comments, declarations and headings.
• Non commented line called as effective lines
  of code or NCLOC.
    Length: Code - LOC /1
 The most commonly used measure of source code
program length is the number of lines of code
(LOC).
       NCLOC: non-commented source line of code or effective
     lines of code (ELOC).
      CLOC: commented source line of code.
 By measuring NCLOC and CLOC separately we
can define:
      total length (LOC) = NCLOC + CLOC
 The ratio: CLOC/LOC measures the density of
  comments in a program.
                                                          7
                     Adv & Disadv
• Advantages of LOC
  – Simple and automatically measurable
  – Correlates with programming effort (& cost)
• Disadvantage of LOC
  – Language dependability
  – Not available for early planning
  – Developers’ skill dependability
            Halstead Metrics
• Maurice Halstead’s Theory (1971~1979):
• A program P is a collection of tokens,
  composed of two basic elements: operands
  and operators ,
• Operands are variables, constants, addresses
• Operators are defined operations in a
  programming                           language
  (language constructs)
      Halstead’s Software Metrics
Following base measures can be collected :
n1 = Number of distinct operators.
n2 = Number of distinct operands.
N1 = Total number of occurrences of operators.
N2 = Total number of occurrences of operands.
            COUNTING RULES
• Comments are not considered.
• Identifiers and function declarations are not
  considered.
• All the variables and constants are operands.
• Function calls are considered as operators.
• All looping statements, all control statements,
  switch case are considered as operators.
• The reserve words like return, continue,break,
  sizeof etc.. are considered as operators.
• All the brackets, commas, terminators are
  considered as operators.
• GOTO is considered as operator and the label is
  considered as operand.
• “Array name” and index are operands.
• Hash derivatives are ignored.
Ex:
if (k< 2)
{
k=3;
x=x*k;
}
                Halstead metrics
Metric                  Meaning        Mathematical
                                       Representation
          n             Vocabulary     n1 + n2
          N             Size           N1 + N2
          V             Volume         Length * Log2 Vocabulary
          D             Difficulty     (n1/2) * (N1/n2)
          E             Efforts        Difficulty * Volume
          B             Errors         Volume / 3000
          T             Testing time   Time = Efforts / S, where
                                       S=18 seconds.
     L = n1/n2, Program Level
Eg:1
•   int sort (int x[ ], int n)
•   {
•   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;
•   }
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
•   N = 91
•   n = 24
•   V = 417 bits
•   D = 37.03
•   L = 0.027
• T = 610 seconds
• Estimated program length N^ = n1log2n1 + n2log2n2
• N^ = 86.45
• Potential Minimum Volume(V*) :
•   the volume of the most short program in which a problem can be
  coded.
•     V* = (2 + n2*) * log2 (2 + n2*)
• V* = 11.6
Eg:2
if (x>5)
{
x= x + 2;
      if(x<7)
{
x=0;
}
}
• Total Length (N)
       N = N1 + N2 = 15 + 9 = 24
• Vocabulary (n)
       n = n1 + n2 = 9 + 5 = 14
• Estimated Length = 1.67
• Volume = N log2 n
               = 24 log2 14
               = 24 x log10 14 / 0.3010
               = 24 x 3.807 = 91.36
• D = N1/ 2 x N2 / n2
• = 9/2 x 9/5 = 81 /10 = 8.1
• Effort = V *D
•       = 91.36 x 8.1 = 740.016
              Halstead’s Metrics
• Advantages
  –   easy to compute (scanner)
  –   Predict maintenance effort
  –   Predict rate of error
  –   Useful in reporting and scheduling projects
  –   Simple to calculate
  –   applicable for all languages
  –   empirical studies: good measure for complexity
• Disadvantages
  – language dependent
                      2. Reuse
• Program generator , fourth generation language , windowing
  environment etc. facilitated the reuse of code.
• Reuse include specification , design , code, documentation
  ,helps to improve productivity and quality
• Reuse measure how much of a product was copied or
  modified.
• Measure extent of reuse
   – Reused verbatim : reuse without an changes
   – Slightly modified:25% of lines are changed
   – Extensively modified:25% or more lines are modified.
   – New: none of the code comes form previously
     constructed.
Reuse Repository
         3. Functionality
• There are 3 method to measure the
  functionality:
• Albrecht’s Approach
• COCOMO-II
• Demarco’s Approach
           Albrecht’s Approach
• In 1979 by A.J Albrecht , then of measuring software
  size and productivity.
• 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.
• Ultimate measure of software productivity is number
  of function a development team can produce.
• Quantifies the size and complexity is measured by
  input , output, inquires , input files and interfaces
• Function Point (FP) is a weighted measure of
   software functionality.
• FP is computed in two steps:
  – 1)     Calculating Unadjusted Function point
    Count (UFC).
  – 2) Multiplying the UFC by a Technical Factor
    count(TFC)
   What are function points?
External              System Boundary
Inquiries
              Internal Files
                                        External
                                        Outputs
External
Interfaces
             External Inputs
       Example:- Spell Checker
• Covert specification to Diagram
Example:
• Given,
      I/P: 5, O/P: 3,Inquiry: 2,Internal logical: 2
      External Interface: 1
                  Complexity of Data/Transaction Function
                       FTR               RET                DET
           EI          10                                    5
           EO           7                                    8
           EQ           5                                    6
           ILF                            9                  7
           ELF                            7                  8
   Compute LOC for the given system using function
   point.(Assume the system was developed using ‘C’).
Solution:
       I/P: 5,
       O/P: 3,
       Inquiry: 2,
       Internal logical: 2
       External Interface: 1
 Complexity of Data/Transaction
           Function
             FTR       RET     DET   Compl         Value   Total
                                      exity
 EI          10                 5      6      *     5       30
 EO           7                 8      7      *     3       21
 EQ           5                 6      6      *     2       12
 ILF                    9       7     10      *     2       20
 ELF                    7       8      7      *     1       7
                                                  UFC       90
• Assume all complexity weights are 5.
• 14*5 = 70
• VAF = 1.35
• FP = UFC * VAF
•    = 90 * 1.35
• FP = 121.5
• our program is written In C,
• Then SLOC is: 17982 lines (121.5 * 148)
OBJECT POINT
Assumed 0%
reuse