Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Metrics Software Engineering.

Similar presentations


Presentation on theme: "Software Metrics Software Engineering."— Presentation transcript:

1 Software Metrics Software Engineering

2 Definitions Measure – the process of assigning numbers to attributes of entities according to some defined rules. E.g., Number of errors Metric – The continuous application of the measurement based techniques to the software development processes and products to supply meaningful information together with use of those techniques to improve software development process and its products E.g., Number of errors found per person

3 Software Metrics Measurement Based Techniques Applied to To Supply
Processes, Products and Services Engineering and Management Information To Improve

4 Why Measure Software? Determine the quality of the current product or process Predict qualities of a product/process Improve quality of a product/process

5 Types of Measures Direct Measures (internal attributes)
Cost, effort, LOC (lines of code), speed, memory size and defects reported over set period of time. Indirect Measures (external attributes) Functionality, quality, complexity, efficiency, reliability, maintainability More difficult to assess

6 Motivation for Metrics
Estimate the cost & schedule of future projects Evaluate the productivity impacts of new tools and techniques Establish productivity trends over time Improve software quality Forecast future staffing needs Anticipate and reduce future maintenance needs

7 Metric Classification
Product Metrics Describe the characteristics of the product, such as size, complexity, design features, performance, efficiency, reliability, portability etc. Process Metrics Activities related to production of software like effort required in the process, time to produce the product, number of defects found during testing, effectiveness of defect removal during development, maturity of the process Project Metrics Describe the project characteristics and execution like number of software developers, cost and schedule, productivity

8 Attributes of Effective Software Metrics
Simple and Computable Consistent and objective Consistent in the use of units and dimensions Programming language independent An effective mechanism for high – quality feedback

9 Halstead's Software Science Metrics
It is an analytical technique to measure size, development effort and development cost of software products. Halstead used a few primitive program parameters to develop the expressions for overall program length, potential minimum value, actual volume, effort and development time.

10 Halstead's Software Science Metrics
Halstead (researcher) proposed that program may be considered as a collection of lexical tokens, each of which can be classified as operator or operand. Operands are the tokens which have value. Data variables and constants therefore constitute the operands. Operators are commas, parenthesis, keywords, arithmetic operators, functions and so on. Tokens that appear in pairs are counted as one token eg. "begin...end", "repeat...until“ etc

11 Halstead's Software Science Metrics
Primitive Measures proposed by Halstead are: the number of unique operators in program the number of unique operands in program N1 = total count of all operators in program. N2 = total count of all operands in program.

12 Halstead's Software Science Metrics - Measures
Halstead length : Total number of operators and operands in a program Vocabulary : Defined as the sum of the number of unique operands and operators used in the program Estimated Program Length : This value can be estimated before the program is written. Program Volume : is the minimum number of bits needed to encode the program

13 Halstead's Software Science Metrics - Measures
Effort Equation : The effort E required to implement the program P is Effort = (n1N2/2n2) (Nlog2n) It correlates with the effort needed for maintenance for small programs. Unit for effort is elementary mental discriminators (emd). Time Equation: Halstead also estimated the time T required to implement the program as T = (E/18) seconds

14 Halstead's Software Science Metrics - Advantages
Simple to calculate Do not require in depth analysis of programming structure Measure overall quality of programs Predicts maintenance effort Useful in scheduling the projects

15 Q. Consider the program code given below
int sum, i; sum = 0; for (i=1; i<=20; i++) sum = sum + i; printf(sum); For this program compute Halstead software science metrics n1 n2 N1 N2 n V E and T.

16 Halstead's Software Science Metrics - Example
List of Operators : List of Operands : PROGRAM Int sum,i; Sum = 0; For (i=1; i<=20; i++) sum = sum + i; Printf(sum); Operator frequency Int 1 , ; 6 = 3 () 2 <= ++ For + Printf Operands frequency Sum 5 i 1 20

17 Halstead's Software Science Metrics - Example
n1 = number of distinct operators = 10 n2 = number of distinct operands = 5 N1 = total number of operator occurrences = 18 N2 = total number of operand occurrences = 13 Vocabulary (n) of program = n1 + n2 = 15 Length of the program = N1 + N2 = 31 Estimated Program Length : n1log2n1 + n2log2n2 = 10log log25 = 10* *2.32 = 44.8 4. Volume (V) = Nlog2n = 31 log215 = 31*3.91 = bits

18 Halstead's Software Science Metrics - Example
n1 = number of distinct operators = 10 n2 = number of distinct operands = 5 N1 = total number of operator occurrences = 18 N2 = total number of operand occurrences = 13 5. Effort = (n1N2/2n2) (Nlog2n) = ((10*13)/(2*5))(31log215) = emd 6. Time = E/18 = /18 = seconds

19 Size-Oriented Metrics - LOC
LOC - Lines Of Code is the simplest among all metrics available to estimate project size. KLOC Lines Of Code SLOC – Statement Lines of Code (ignore whitespace) Project size is estimated by counting the number of source instructions in the developed program. Typical Measures: Errors/KLOC, Defects/KLOC, Cost/LOC, Documentation Pages/KLOC

20 Size Metric- Lines of Code(LOC)
The basic and simplest metric for the size is Lines of code(LOC) often quoted in 1000’s (KLOC). In a real sense this metric measures the length of a program which is a logical characteristic but not size which is physical characteristic of the program. While number of lines, normally researchers are of the view that comments and blank lines should not be counted. Comments used in the program make the program understandable and easier to maintain but effort required for writing the comments is not as much as writing the code. According to some researchers LOC mat be computed by counting the new-line characters in the program. This metric can also be used in other indirect measures as well, such as Productivity = LOC/Effort

21 LOC Metrics Advantages Disadvantages Easy to use Easy to compute
Language & programmer dependent Bad software design may cause excessive line of code Defined on code User cannot easily understand it

22 Measuring Functionality – Function Point Analysis (FPA)
FPA is a popular method which uses complexity and the number of functions supported by the software to compute the size of the software in terms of Function Point Count (FPC). Concept : the size of the software being developed is directly proportional to the number of functions it will support. Each of these functions are characterized by the inputs taken, outputs given, interfaces and the number of files used. All these factors contribute in calculating total function points.

23 Flowchart for computing Function Points
Start Specify the Functional Requirement Project Count Data Function Type and Transaction Function Type Compute Unadjusted Function Point (UFP) Apply General Characteristics Compute Value Adjustment Factor (VAF) Adjusted Compute Function Point from UFP and VAF End

24 Steps for Computing Function Points
Identify and Count following functions : External Inputs (EI) : user or control data entering the system. External Outputs (EO) : user or control data coming out of the system. External Inquiries (EIQ) : they do not change the system data. They represent input – output combination. Internal Files (IF) : maintained and understood by customers External Interface (EIF) : files which are shared by the system and other programs. They are not maintained by the software.

25 Steps for Computing Function Points
Calculate Unadjusted Function Points : Identify the complexity level of data function type and transaction function type Their complexity depends on the number of data element types and file types referenced. Once the unadjusted function points are computed, then based on their complexity level they are multiplied by the weighing factors as follows: Simple Average Complex EI 3 4 6 EO 5 7 EIQ IF 10 15 EIF

26 Steps for Computing Function Points
Apply 14 general characteristics : The 14 characteristics are : data communications, performance, transaction rate, processing, reusability, end user efficiency, online update, configuration, multiple sites, operations, change requirements, distributed processing, online data entry and installation. These characteristics have rating 0 – 5 which influence Function Point Count (FPC) Sum of these 14 general characteristics rating can be between 0 – 70 and is called Total Degree of Influence (TDI)

27 Steps for Computing Function Points
Compute the Value Adjustment Factor (VAF) VAF = (TDI * 0.01) Calculate Function Point count (FPC) FPC = UFP * VAF FP are not suitable for algorithmically intensive systems such as embedded systems and real time systems. In such type of systems function points called feature points are used for estimating the size.

28 Advantages of Function Point Technique
Function Points(FP) can be computed early in the project and are directly derived from SRS. FP are independent of the technology (ie. Programming languages, database etc. ) used to develop the software. It can be used as a technique to measure the productivity of the projects written in different languages.

29 Function Point Technique - Example
Consider a project with following data: Number of external inputs with low complexity = 10 Number of external inputs with high complexity = 10 Number of external outputs with average complexity = 15 Number of external inquiries with average complexity = 13 Number of internal logical files with high complexity = 2 Number of internal logical files with low complexity = 2 Number of external interface files with average complexity = 7 The system has a very high transaction rate and supports several multiple communication protocols. Calculate the unadjusted as well as adjusted function points.

30 Function Point Technique - Example
Solution: Total unadjusted function points (UFP) after considering the weighting factors are given by : UFP = 3 * * * * * * * 7 = = 310 The software also supports high transaction rate and multiple communication protocols. Hence these two system characteristics can be assigned a rating of 5. TDI = =10 VAF = (TDI * 0.01) = (10 * 0.01) = 0.75 Adjusted function points FPC = UFP * VAF = 310 * 0.75 = 232.5

31 McCabe’s Cyclomatic Complexity Metric
It is a metric to measure logical complexity of the program. McCabe’s metrics are based on a control flow representation of the program. It defines the number of independent paths in the program to be executed in order to ensure that all statements in the program are executed at least once. In other words it gives us the value for maximum number of est cases to be designed. A program graph is used to depict control flow. Nodes represent processing tasks (one or more code statements) Edges represent control flow between nodes

32 Flow Graph Notation While Sequence If-then-else Until Case

33 Ways to compute Cyclomatic Complexity
The cyclomatic complexity C(G) of a graph G can be computed using one of the following ways: C(G) = E – N + 2 E is the number of flow graph edges N is the number of nodes C(G) = number of regions in the flow graph. Regions are the areas bounded by nodes and edges in a flow graph. While counting regions, area outside the graph is also counted as one region. C(G) = P + 1 P is the number of predicate nodes

34 Example main() { int num_student, marks, subject, total;
float average; num_student = 1; while(num_student <=25) { total = 0; subject = 1; while(subject<=5){ scanf(“Enter marks:%d”, &marks); total = total + marks subject ++; } average = total/5; If(average>=50) printf(“Pass...Average is %f”, average); else printf(“Fail...Average is %f”, average); num_student++; 20. printf({“End of Program”); 21. } Nodes State ment Numbers a 2-4 b 5 e 6-7 f 8 z 9-12 g 13-14 h 15 i 17 j 18 c 19 d 20

35 Flow Graph a b e f z g h i j c d

36 Ways to compute Cyclomatic Complexity
The cyclomatic complexity C(G) of a graph G can be computed using one of the following ways: C(G) = E – N + 2 E =13, N=11 C(G)= =4 C(G) = number of regions in the flow graph= 4 C(G) = P + 1 =3+1 =4


Download ppt "Software Metrics Software Engineering."

Similar presentations


Ads by Google