Software Metrics (Part II). Product Metrics  Product metrics are generally concerned with the structure of the source code (example LOC).  Product metrics.

Slides:



Advertisements
Similar presentations
Evaluation of Abstraction Techniques. Uses for the complexity metrics in our framework Comparing the complexity of the reference model with the abstracted.
Advertisements

Experiments and Variables
1 Ivan Marsic Rutgers University LECTURE 15: Software Complexity Metrics.
CYCLOMATIC COMPLEXITY 1. Invented by Thomas McCabe (1974) to measure the complexity of a program ’ s conditional logic Cyclomatic complexity of graph.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
David Woo (dxw07u).  What is “White Box Testing”  Data Processing and Calculation Correctness Tests  Correctness Tests:  Path Coverage  Line Coverage.
Software Metrics and Design Principles. What is Design? Design is the process of creating a plan or blueprint to follow during actual construction Design.
1 Static Analysis Methods CSSE 376 Software Quality Assurance Rose-Hulman Institute of Technology March 20, 2007.
Detailed Design Kenneth M. Anderson Lecture 21
Software Metrics II Speaker: Jerry Gao Ph.D. San Jose State University URL: Sept., 2001.
IMSE Week 18 White Box or Structural Testing Reading:Sommerville (4th edition) ch 22 orPressman (4th edition) ch 16.
1 Complexity metrics  measure certain aspects of the software (lines of code, # of if-statements, depth of nesting, …)  use these numbers as a criterion.
Overview Software Quality Metrics Black Box Metrics White Box Metrics
A Complexity Measure THOMAS J. McCABE Presented by Sarochapol Rattanasopinswat.
Cyclomatic Complexity Dan Fleck Fall 2009 Dan Fleck Fall 2009.
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 02.
University of Toronto Department of Computer Science © 2001, Steve Easterbrook CSC444 Lec22 1 Lecture 22: Software Measurement Basics of software measurement.
Software Metrics.
Software Metrics *** state of the art, weak points and possible improvements Gordana Rakić, Zoran Budimac Department of Mathematics and Informatics, Faculty.
Prof. Mohamed Batouche Software Testing.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 20 Slide 1 Defect testing l Testing programs to establish the presence of system defects.
1 Software Quality CIS 375 Bruce R. Maxim UM-Dearborn.
SWEN 5430 Software Metrics Slide 1 Quality Management u Managing the quality of the software process and products using Software Metrics.
Software Measurement & Metrics
Software Life Cycle Requirements and problem analysis. –What exactly is this system supposed to do? Design –How will the system solve the problem? Coding.
Product Metrics An overview. What are metrics? “ A quantitative measure of the degree to which a system, component, or process possesses a given attribute.”
Software Metrics Software Engineering.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Lecture 23 Instructor Paulo Alencar.
Software Function, Source Lines Of Code, and Development Effort Prediction: A Software Science Validation ALLAN J. ALBRECHT AND JOHN E.GAFFNEY,JR., MEMBER,IEEE.
OHTO -99 SOFTWARE ENGINEERING “SOFTWARE PRODUCT QUALITY” Today: - Software quality - Quality Components - ”Good” software properties.
Software Quality Metrics
Chapter 12: Design Phase n 12.1 Design and Abstraction n 12.2 Action-Oriented Design n 12.3 Data Flow Analysis n Data Flow Analysis Example n
V Spanning Trees Spanning Trees v Minimum Spanning Trees Minimum Spanning Trees v Kruskal’s Algorithm v Example Example v Planar Graphs Planar Graphs v.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
Creator: ACSession No: 7 Slide No: 1Reviewer: SS CSE300Advanced Software EngineeringSeptember 2005 Software Measurement – Estimation and Productivity CSE300.
Measure18 1 Software Measurement Halstead’s Software Science.
Software Metrics.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
CSC 480 Software Engineering Testing - I. Plan project Integrate & test system Analyze requirements Design Maintain Test units Implement Software Engineering.
Graph theory and networks. Basic definitions  A graph consists of points called vertices (or nodes) and lines called edges (or arcs). Each edge joins.
Agent program is the one part(class)of Othello program. How many test cases do you have to test? Reversi [Othello]
Martin Hoffman Monica Hoffman. Goal To determine if a correlation exists between specified internal and dependability (external) metrics.
CS223: Software Engineering Lecture 21: Unit Testing Metric.
Dynamic White-Box Testing What is code coverage? What are the different types of code coverage? How to derive test cases from control flows?
CHAPTER 9 - PART 2 Software Testing Strategies. Lesson Outlines ■ White box testing – Data processing and calculation correctness tests – Correctness.
Software METRICS. Intro Measurement is essential to life economic measurement... clinical measurement... air traffic control... etc., etc., etc....
A Discourse on Complexity of Process Models J. CardosoUniversidade da Madeira J. MendlingVienna University of Economics G. NeumannVienna University of.
Metrics of Software Quality
Software Metrics 1.
Software Testing.
Software Testing.
Cyclomatic complexity
Design Characteristics and Metrics
Software metric By Deepika Chaudhary.
Halstead’s software science: An analystical model
Software Engineering (CSI 321)
Ch9: Decision Trees 9.1 Introduction A decision tree:
CPSC 873 John D. McGregor GQM.
Lecture 17 Software Metrics
Software Testing (Lecture 11-a)
CS223: Software Engineering
Halstead software science measures and other metrics for source code
Presented by Trey Brumley and Ryan Carter
Chapter 19 Technical Metrics for Software
Software Testing “If you can’t test it, you can’t design it”
Software Effort Estimation
1. Cyclomatic complexity
Chapter 8: Design: Characteristics and Metrics
Presentation transcript:

Software Metrics (Part II)

Product Metrics  Product metrics are generally concerned with the structure of the source code (example LOC).  Product metrics are metrics that can be calculated independent of how the document is produced.  They can be calculated for other documents too. For example the number of words in a requirements specification.

McCabe’s Cyclomatic Number  McCabes cyclomatic number (also called McCabe’s complexity measure), after LOC, is one of the most commonly used software metrics.  It was introduced in  It is based on graph theory’s cyclomatic number. Thomas McCabe Sr.

A Little Graph Theory  A graph G is planar if it can be drawn on a plane so that none of its edges cross. Planar or not?

Strongly Connected Graphs  A directed graph G is strongly connected if thee is a path from any node to any other node. Strongly Connected Not Strongly Connected

Weakly Connected Graphs  A graph G is weakly connected, if every node can reach every other node and you don’t care which way the directed edges point. Weakly Connected Not Weakly Connected

Strongly Connected Components  A strongly connected component of a graph G is a maximal subgraph of G that is strongly connected. What are the strongly connected component?

Euler’s Theorem e = the number of edges n = the number of nodes r = the number of regions formed by the graph Leonhard Euler ( ) proved that for a planar graph G: where 2 = n – e + r

Euler’s Theorem  n =  e =  r = n – e + r = Consider the graph below

McCabe’s Cyclomatic Number  2 = n – e + r can be rewritten to find the number of regions in a planar graph knowing the number of nodes and edges: r = e – n + 2  McCabe used the number of regions formed by a control flow graph as his software metric and named it “McCabe’s Complexity Measure”

McCabe’s Cyclomatic Number  McCabe generalized the number for graphs that contained more than one strongly connected component as: Cyclomatic number (C) = e – n + 2p where p = number of strongly connected components

McCabe’s Cyclomatic Number  Find McCabe’s cyclomatic number for the following control flow graph:

 Calculate McCabe’s cyclomatic number for the following code: /* main routine */ x := 1; while (x = 1) { x := 2; test ( x, 1 ); x := 3; } // End while while (x = 1) { x := 4; x := 5; test ( x, 2 ); } //End while While (x = 1) { x := 6; if (x = 7)x := 8; else test ( x, 3 ); } // End while } // End main

Threshold  McCabe analyzed large projects and found that when the cyclomatic number for a module exceeds 10, there is a history of many more errors and difficulties in maintenance.

Halstead Measure (1977)  Maurice Halstead did his work in the late 1960’s and early 1970’s.  He was a pioneer in software metrics (as was McCabe).  His goal was to find out what contributed to software complexity.

Halstead Metrics  A program is considered to be a collection of tokens.  Tokens are either operators or operands.  Operands were tokens that had a value (typically variables or constants).  Everything else is an operator (commas parenthesis, arithmetic operators, i.e. all the C++ operators)

Halstead Metrics  All tokens that occur as pairs, triples, etc. count as one token (example: parenthesis).  Halstead did not count declarations, input or output statements, or comments do not count as tokens.  Most organizations currently count all parts of a program.

Halstead Metrics  The count of unique operators is ή 1 (eta one) and the count of unique operands is ή 2 (eta two). z = 0; While x > 0 z = z + y; x = x – 1 End-while; Print (z); Consider the code below: Operators: =While; +->Print ( ) Operands: ή 1 = 8 z0xy1 ή 2 = 5

Halstead Metrics  The length (N) of the program is the total count of operators and operands. For example, for: z = 0; While x > 0 z = z + y; x = x – 1 End-while; Print (z); Number of operands = 11 Number of operators = 14 N = 25

Halstead Metrics  The Estimate of Length (est N or N_hat) is defined as: Est N = ή 1 * log 2 ή 1 + ή 2 * log 2 ή 2 Est N = ή 1 * log 2 ή 1 + ή 2 * log 2 ή 2  This formula can be used to estimate the total number of tokens, based on the number of different tokens.  The author of your book has found that if N and Est N differ by more than 30%, then it may not be reasonable to apply other software science measures.  Then again, it may be!

Halstead Metrics  Halstead’s measure: Est N = ή 1 * log 2 ή 1 + ή 2 * log 2 ή is based on Claude Shannon’s formula for entropy (the amount of information in something) in information theory. H = n * log S where S is the number of possible symbols, and n the number of symbols in a transmission April 30, 1916 – February 24, 2001

Halstead Metrics  For the code: z = 0; While x > 0 z = z + y; x = x – 1 End-while; Print (z); ή 1 = 8 ή 2 = 5 Est N = 8 log log 2 5 Est N = 8 * * 2.32 Est N = 35.6 N = 25 difference = 10.6 / 35.6 = 29.8%

Volume  The volume of a program is related to the number of bits needed to encode the program  The volume of a program is defined as: V = N * log 2 (ή 1 + ή 2 ) For our sample code: V = 25 * log 2 (8 + 5) = 25 *3.7 = 25 *3.7 = 92.5 = 92.5

Potential Volume  The potential volume is the minimal size of a solution solved in any language.  Halstead defined the potential volume as: V* = (2 + ή 2 *) log 2 (ή 2 *) Where ή 2 * is the minimum set of operands needed to implement the algorithm in any language.

Implementation Level  The implementation level is defined as: L = Potential Volume / Volume = V* / V  This relates to how close the current implementation is to the minimal implementation.

Henry–Kafura Information Flow  Sallie Henry and Dennis Kafurn developed a software metric to measure the intermodule complexity of code.  For a module, a count is made of all the information flows into the module (fan-ins) and all the information flows out of the module (fan-outs).

Henry–Kafura Information Flow  The information flows include: Parameters Global variables Inputs and outputs HK = weight * (out * in) 2 Where the weight is determined by the size of the module and the HK’s are summed over all modules.  Their formula is (for a single module)

Advantages: Henry–Kafura Information Flow  They look at higher level complexity, while McCabe looks at lower level complexity. McCabe’s complexity can only be applied when you have detail source code or pseudo-code.  Henry and Kafura’s complexity can be applied during design phase and also at scoping phase if proper information flow block diagrams are drawn

Disadvantages: Henry–Kafura Information Flow  If fan-in or fan-out is zero the whole complexity will become zero.  Just imagine you are using Henry and Kafura’s complexity and fan-in or fan-out is zero the quotation is zero Dollars.

Disadvantages: Henry–Kafura Information Flow  The length factor is a completely different attribute.  Multiplication of the factor with complexity has been questioned by experts.  Arthimetic calculations can be performed on measurements of similar type.  Example adding 1 litre + 10 volts will yield nothing sensible

The End