Chapter 9: Software Metrics

Slides:



Advertisements
Similar presentations
Software Metrics for Object Oriented Design
Advertisements

Software Metrics Software Engineering.
Metrics for Process and Projects
Metrics for Process and Projects
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
Figures – Chapter 24.
March 25, R. McFadyen1 Metrics Fan-in/fan-out Lines of code Cyclomatic complexity Comment percentage Length of identifiers Depth of conditional.
Nov R. McFadyen1 Metrics Fan-in/fan-out Lines of code Cyclomatic complexity* Comment percentage Length of identifiers Depth of conditional.
Software Metrics.
Object-Oriented Metrics. Characteristics of OO ● Localization ● Encapsulation ● Information hiding ● Inheritence ● Object abstraction.
Software engineering for real-time systems
Software Engineering II - Topic: Software Process Metrics and Project Metrics Instructor: Dr. Jerry Gao San Jose State University
Software Metrics II Speaker: Jerry Gao Ph.D. San Jose State University URL: Sept., 2001.
Object-Oriented Metrics
March R. McFadyen1 Software Metrics Software metrics help evaluate development and testing efforts needed, understandability, maintainability.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
Predicting Class Testability using Object-Oriented Metrics M. Bruntink and A. van Deursen Presented by Tom Chappell.
Object Oriented Metrics XP project group – Saskia Schmitz.
Software Process and Product Metrics
Lecture 17 Software Metrics
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Refactoring.
Object-Oriented Metrics Alex Evans Jonathan Jakse Cole Fleming Matt Keran Michael Ababio.
1 Software Quality CIS 375 Bruce R. Maxim UM-Dearborn.
Chapter 6 : Software Metrics
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
Software Measurement & Metrics
1. Software Metric- A definition 2. Types of Software metrics 3. Frame work of product metrics 4. Product metrics.
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter.
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.
The CK Metrics Suite. Weighted Methods Per Class b To use this metric, the software engineer must repeat this process n times, where n is the number of.
Software Project Management Lecture # 3. Outline Chapter 22- “Metrics for Process & Projects”  Measurement  Measures  Metrics  Software Metrics Process.
OHTO -99 SOFTWARE ENGINEERING “SOFTWARE PRODUCT QUALITY” Today: - Software quality - Quality Components - ”Good” software properties.
Software Metrics (Part II). Product Metrics  Product metrics are generally concerned with the structure of the source code (example LOC).  Product metrics.
Software Quality Metrics
Concepts of Software Quality Yonglei Tao 1. Software Quality Attributes  Reliability  correctness, completeness, consistency, robustness  Testability.
Lecture 4 Software Metrics
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
1 Metrics and lessons learned for OO projects Kan Ch 12 Steve Chenoweth, RHIT Above – New chapter, same Halstead. He also predicted various other project.
An Automatic Software Quality Measurement System.
SOFTWARE METRICS. Software Process Revisited The Software Process has a common process framework containing: u framework activities - for all software.
Computing and SE II Chapter 15: Software Process Management Er-Yu Ding Software Institute, NJU.
SOFTWARE PROCESS AND PROJECT METRICS. Topic Covered  Metrics in the process and project domains  Process, project and measurement  Process Metrics.
CSc 461/561 Information Systems Engineering Lecture 5 – Software Metrics.
Measurement and quality assessment Framework for product metrics – Measure, measurement, and metrics – Formulation, collection, analysis, interpretation,
Software Testing White Box Testing. Agenda What is White Box Testing Correctness Tests and Path Coverage Correctness Tests and Line Coverage McCabe Cyclomatic.
1 Software Engineering: A Practitioner’s Approach, 6/e Chapter 15a: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter.
1 These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 5/e and are provided with permission by.
Hussein Alhashimi. “If you can’t measure it, you can’t manage it” Tom DeMarco,
Advanced Software Engineering Lecture 4: Process & Project Metrics.
Metrics "A science is as mature as its measurement tools."
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Object Oriented Metrics
Software Engineering Object Oriented Metrics. Objectives 1.To describe the distinguishing characteristics of Object-Oriented Metrics. 2.To introduce metrics.
CS223: Software Engineering Lecture 21: Unit Testing Metric.
Software Test Metrics When you can measure what you are speaking about and express it in numbers, you know something about it; but when you cannot measure,
Object Oriented Metrics
Software Metrics 1.
Course Notes Set 12: Object-Oriented Metrics
Design Characteristics and Metrics
McCall’s Quality Factors
Lecture 15: Technical Metrics
Object-Oriented Metrics
Design Metrics Software Engineering Fall 2003
Design Metrics Software Engineering Fall 2003
Software engineering.
Software Metrics “How do we measure the software?”
Software metrics.
Software Metrics SAD ::: Fall 2015 Sabbir Muhammad Saleh.
Chapter 8: Design: Characteristics and Metrics
Presentation transcript:

Chapter 9: Software Metrics Omar Meqdadi SE 3860 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville

Topic Covered Introduction Complexity Metrics Software Quality Metrics Module Design Metrics Object Oriented Metrics

Introduction Measure - quantitative indication of extent, amount, dimension, capacity, or size of some attribute of a product or process. E.g., Number of errors Metric - quantitative measure of degree to which a system, component or process possesses a given attribute. “A handle or guess about a given attribute.” E.g., Number of errors found per person hours expended

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

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

Metric Classification Products Explicit results of software development activities Deliverables, documentation, by products Processes Activities related to production of software Resources Inputs into the software development activities hardware, knowledge, people

Product vs. Process Process Metrics Product Metrics Insights of process paradigm, software engineering tasks, work product, or milestones Lead to long term process improvement Product Metrics Assesses the state of the project Track potential risks Uncover problem areas Adjust workflow or tasks Evaluate teams ability to control quality

Types of Measures Direct Measures (internal attributes) Cost, effort, LOC, speed, memory Indirect Measures (external attributes) Functionality, quality, complexity, efficiency, reliability, maintainability

Size-Oriented Metrics Size of the software produced LOC - Lines Of Code KLOC - 1000 Lines Of Code SLOC – Statement Lines of Code (ignore whitespace) Typical Measures: Errors/KLOC, Defects/KLOC, Cost/LOC, Documentation Pages/KLOC

LOC Metrics Easy to use Easy to compute Language & programmer dependent

Complexity Metrics Language and programmer dependent LOC - a function of complexity Halstead’s Software Science (entropy measures) n1 - number of distinct operators n2 - number of distinct operands N1 - total number of operators N2 - total number of operands

Example if (k < 2) { if (k > 3) x = x*k; } Distinct operators: if , ( , ), { }, >, <, =, and * Distinct operands: k , 2 , 3 , and x n1 = 10 n2 = 4 N1 = 13 N2 = 7

Halstead’s Metrics Program length: N = N1 + N2 Program vocabulary: n = n1 + n2 Estimated length: = n1 log2 n1 + n2 log2 n2 Close estimate of length for well structured programs Purity ratio: PR = /N

Halstead’s Metrics Program Complexity Volume: V = N log2 n Difficulty Number of bits to provide a unique designator for each of the n items in the program vocabulary. Difficulty Program effort: E=D*V This is a good measure of program comprehension (understandability)

McCabe’s Complexity Measures McCabe’s metrics are based on a control flow representation of the program. A program graph is used to depict control flow. Nodes represent processing tasks (one or more code statements) Edges represent control flow between nodes

Flow Graph Notation While Sequence If-then-else Until

Example i = 0; while (i<n-1) do j = i + 1; while (j<n) do if A[i]<A[j] then swap(A[i], A[j]); end do; i=i+1;

Flow Graph 1 2 3 7 4 5 6

Cyclomatic Complexity V(G) : Set of independent paths through the graph (basis set) V(G) = E – N + 2 E is the number of flow graph edges N is the number of nodes V(G) = P + 1 P is the number of predicate nodes (A predicate node is a node containing a condition)

Computing V(G) V(G) = 9 – 7 + 2 = 4 V(G) = 3 + 1 = 4 Basis set of independent paths: 1, 7 1, 2, 6, 1, 7 1, 2, 3, 4, 5, 2, 6, 1, 7 1, 2, 3, 5, 2, 6, 1, 7

Another Example 1 9 2 4 3 5 6 7 8 What is V(G)?

Meaning V(G) is the number of (enclosed) regions/areas of the planar graph Number of regions increases with the number of decision paths and loops A quantitative measure of testing difficulty An indication of ultimate reliability Experimental data shows value of V(G) should be no more then 10 - testing is very difficulty above this value

McClure’s Complexity Metric Represents the decisional complexity Complexity = C + V C is the number of comparisons in a module V is the number of control variables referenced in the module Similar to McCabe’s but with regard to control variables

Metrics and Software Quality Functionality - features of system Usability – aesthesis, documentation Reliability – frequency of failure, security Performance – speed, throughput Supportability – maintainability

Measures of Software Quality Correctness – degree to which a program operates according to specification Defects/KLOC Defect is a verified lack of conformance to requirements Failures/hours of operation Maintainability – degree to which a program is open to change Mean time to change Change request to new version (Analyze, design etc) Cost to correct Integrity - degree to which a program is resistant to outside attack Fault tolerance, security & threats Usability – easiness to use Training time, skill level necessary to use, Increase in productivity, subjective questionnaire or controlled experiment

McCall’s Triangle of Quality b l y P o r t a b i l y F l e x i b t y R e u s a b i l t y T e s t a b i l y I n t e r o p a b i l y P R O D U C T E V I S N P R O D U C T A N S I P R O D U C T E A I N C o r e c t n s U s a b i l t y E f i c e n y R e l i a b t y I n t e g r i y

A Comment McCall’s quality factors were proposed in the early 1970s. They are as valid today as they were in that time. It’s likely that software built to conform to these factors will exhibit high quality well into the 21st century, even if there are dramatic changes in technology.

Quality Model Metrics product operation revision transition reliability efficiency usability maintainability testability portability reusability Metrics

Module Design Metrics Module complexity metrics: Structural Complexity Data Complexity System Complexity Structural Complexity: S(i) of a module i. S(i) = fout2(i) Fan out is the number of modules immediately subordinate (directly invoked).

Module Design Metrics Data Complexity: System Complexity: D(i) of a module i. D(i) = v(i)/[fout(i)+1] v(i) is the number of inputs and outputs passed to and from i System Complexity: C(i) of a module i. C(i) = S(i) + D(i) As each increases the overall complexity of the architecture increases

Object Oriented Metrics Metrics specifically designed to address object oriented software Class oriented metrics Direct measures

Depth of Inheritance Tree (DIT) DIT is the maximum length from a node to the root (base class) Viewpoints: Lower level subclasses inherit a number of methods making behavior harder to predict Deeper trees indicate greater design complexity

Number of Children(NOC) NOC the number of immediate subclasses of a class in a hierarchy Viewpoints: As NOC grows, reuse increases - but the abstraction may be diluted Depth is generally better than breadth in class hierarchy, since it promotes reuse of methods through inheritance Classes higher up in the hierarchy should have more sub-classes then those lower down NOC gives an idea of the potential influence a class has on the design: classes with large number of children may require more testing

Number of Operations Overridden NOO A large number for NOO indicates possible problems with the design Poor abstraction in inheritance hierarchy

Number of Operations Added NOA The number of operations added by a subclass As operations are added it is farther away from super class As depth increases, NOA should decrease

Class Size (CS) CS Total number of operations (inherited, private, public) plus Total Number of attributes (inherited, private, public) May be an indication of too much responsibility for a class

Method Inheritance Factor(MIF) n = total number of classes in the hierarchy Mi(Ci) is the number of methods inherited and not overridden in the class Ci Ma(Ci) = Mi(Ci) + Md(Ci) Ma(Ci) is the all methods that can be invoked in the Ci = methods declared (new or overridden ) + things inherited Md(Ci) is the number of methods declared in Ci

MIF MIF meaning: MIF is [0,1] MIF near 1 means little specialization MIF near 0 means large change

Polymorphism Factor(PF) TC= total number of classes in the class hierarchy Mn(Ci ) = Number of New Methods of class Ci Mo(Ci ) = Number of Overriding Methods of class Ci DC(Ci ) = Descendants Count of class Ci

Weighted Methods per Class WMC = ci is the complexity (e.g., volume, cyclomatic complexity, etc.) of each method Viewpoints: An indicator of how much time and effort is required to develop and maintain the object The larger the number of methods in an object means: Greater the potential impact on the children Objects are likely to be more application specific, limiting the possible reuse

Response For a Class (RFC) RFC is defined as set of methods that can be potentially executed in response to a message received by an object of that class (local + remote) It is given by RFC= Size of RS, where RS, the response set of the class, is given by Mi = set of all methods in a class (total n) and Ri = {Rij} = set of methods called by Mi Viewpoints: As RFC increases testing effort increases greater the complexity of the object harder it is to understand

Coupling between Classes CBO is the number of collaborations between two classes (fan-out of a class C) The number of other classes that are referenced in the class C (a reference to another class, A, is an reference to a method or a data member of class A) Viewpoints: As collaboration increases reuse decreases High fan-outs represent class coupling to other classes/objects and thus are undesirable High fan-ins represent good object designs and high level of reuse Difficult to maintain high fan-in and low fan outs across the entire system

Metric Tools McCabe & Associates ( founded by Tom McCabe, Sr.) The Visual Quality ToolSet The Visual Testing ToolSet The Visual Reengineering ToolSet Metrics calculated McCabe Cyclomatic Complexity McCabe Essential Complexity Module Design Complexity Integration Complexity Lines of Code Halstead

CCCC A metric analyser C, C++, Java, Ada-83, and Ada-95 (by Tim Littlefair of Edith Cowan University, Australia) Metrics calculated Lines Of Code (LOC) McCabe’s cyclomatic complexity C&K suite (WMC, NOC, DIT, CBO) Generates HTML and XML reports freely available http://cccc.sourceforge.net/

Jmetric OO metric calculation tool for Java code (by Cain and Vasa for a project at COTAR, Australia) Requires Java 1.2 (or JDK 1.1.6 with special extensions) Metrics Lines Of Code per class (LOC) Cyclomatic complexity LCOM (by Henderson-Seller) Availability is distributed under GPL http://www.it.swin.edu.au/projects/jmetric/products/jmetric/

JMetric Tool Results

GEN++ GEN++ is an application-generator for creating code analyzers for C++ programs simplifies the task of creating analysis tools for the C++ several tools have been created with GEN++, and come with the package these can both be used directly, and as a springboard for other applications   Freely available http://www.cs.ucdavis.edu/~devanbu/genp/down-red.html

More Tools on Internet A Source of Information for Mission Critical Software Systems, Management Processes, and Strategies http://www.niwotridge.com/Resources/PM-SWEResources/SWTools.htm Defense Software Collaborators (by DACS) http://www.thedacs.com/databases/url/key.hts?keycode=3 http://www.qucis.queensu.ca/Software-Engineering/toolcat.html#label208 Object-oriented metrics http://me.in-berlin.de/~socrates/oo_metrics.html Software Metrics Sites on the Web (Thomas Fetcke) Metrics tools for C/C++ (Christofer Lott) http://www.chris-lott.org/resources/cmetrics/