March 200391.3913 R. McFadyen1 Software Metrics Software metrics help evaluate development and testing efforts needed, understandability, maintainability.

Slides:



Advertisements
Similar presentations
CLUSTERING SUPPORT FOR FAULT PREDICTION IN SOFTWARE Maria La Becca Dipartimento di Matematica e Informatica, University of Basilicata, Potenza, Italy
Advertisements

Software Metrics for Object Oriented Design
Software Metrics Software Engineering.
Software Metrics. Views on Testing Categories of Metrics Review of several OO metrics CEN 5076 Class 7 – 10/17.
Figures – Chapter 24.
Applying and Interpreting Object Oriented Metrics
March 25, R. McFadyen1 Metrics Fan-in/fan-out Lines of code Cyclomatic complexity Comment percentage Length of identifiers Depth of conditional.
April 1, R McFadyen1 A Traditional Software Development Process Unit test Integration test System test Detailed design Architectural design.
Nov R McFadyen1 A Traditional Software Development Process Unit test Integration test System test Detailed design Architectural design Analysis.
Nov R. McFadyen1 Metrics Fan-in/fan-out Lines of code Cyclomatic complexity* Comment percentage Length of identifiers Depth of conditional.
Page 1 Building Reliable Component-based Systems Chapter 7 - Role-Based Component Engineering Chapter 7 Role-Based Component Engineering.
Design Metrics Software Engineering Fall 2003 Aditya P. Mathur Last update: October 28, 2003.
Software engineering for real-time systems
© S. Demeyer, S. Ducasse, O. Nierstrasz Duplication.1 7. Problem Detection Metrics  Software quality  Analyzing trends Duplicated Code  Detection techniques.
7. Metrics in Reengineering Context
Object-Oriented Metrics
1 Complexity metrics  measure certain aspects of the software (lines of code, # of if-statements, depth of nesting, …)  use these numbers as a criterion.
Software Metrics portions ©Ian Sommerville 1995
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.
Comp 587 Parker Li Bobby Kolski. Automated testing tools assist software engineers to gauge the quality of software by automating the mechanical aspects.
Software Metrics.
Cyclomatic Complexity Dan Fleck Fall 2009 Dan Fleck Fall 2009.
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.
Paradigm Independent Software Complexity Metrics Dr. Zoltán Porkoláb Department of Programming Languages and Compilers Eötvös Loránd University, Faculty.
SWEN 5430 Software Metrics Slide 1 Quality Management u Managing the quality of the software process and products using 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 Engineering: A Practitioner’s Approach, 6/e Chapter 15b: Product Metrics for Software Software Engineering: A Practitioner’s Approach, 6/e Chapter.
1 Software Testing. 2 Path Testing 3 Structural Testing Also known as glass box, structural, clear box and white box testing. A software testing technique.
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.
1 OO Metrics-Sept2001 Principal Components of Orthogonal Object-Oriented Metrics Victor Laing SRS Information Services Software Assurance Technology Center.
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 Quality Metrics
Concepts of Software Quality Yonglei Tao 1. Software Quality Attributes  Reliability  correctness, completeness, consistency, robustness  Testability.
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 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
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.
CSc 461/561 Information Systems Engineering Lecture 5 – Software Metrics.
Software Metrics.
Measurement and quality assessment Framework for product metrics – Measure, measurement, and metrics – Formulation, collection, analysis, interpretation,
Intelligent Database Systems Lab 國立雲林科技大學 National Yunlin University of Science and Technology Mining Source Code Elements for Comprehending Object- Oriented.
Object-Oriented (OO) estimation Martin Vigo Gabriel H. Lozano M.
Ontology Support for Abstraction Layer Modularization Hyun Cho, Jeff Gray Department of Computer Science University of Alabama
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 Lecture 19: Object-Oriented Testing & Technical Metrics.
1 OO Technical Metrics CIS 375 Bruce R. Maxim UM-Dearborn.
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.
Dynamic White-Box Testing What is code coverage? What are the different types of code coverage? How to derive test cases from control flows?
Design Metrics CS 406 Software Engineering I Fall 2001 Aditya P. Mathur Last update: October 23, 2001.
Object Oriented Metrics
Software Metrics 1.
Course Notes Set 12: Object-Oriented Metrics
Design Characteristics and Metrics
Object-Oriented Metrics
CS427: Software Engineering I
Design Metrics Software Engineering Fall 2003
Design Metrics Software Engineering Fall 2003
Lecture 17 Software Metrics
Information flow-Test coverage measure
Mei-Huei Tang October 25, 2000 Computer Science Department SUNY Albany
Software Metrics SAD ::: Fall 2015 Sabbir Muhammad Saleh.
Software Metrics using EiffelStudio
1. Cyclomatic complexity
Chapter 8: Design: Characteristics and Metrics
Presentation transcript:

March R. McFadyen1 Software Metrics Software metrics help evaluate development and testing efforts needed, understandability, maintainability and reusability of software.

March R. McFadyen2 Metrics Fan-in/fan-out Lines of code Cyclomatic complexity* Comment percentage Length of identifiers Depth of conditional nesting Fog index Weighted methods per class Response for a class Lack of cohesion of methods Coupling between objects* Depth of inheritance tree Number of children Number of overriding operations TraditionalObject-Oriented * March 2003 see

March R. McFadyen3 Traditional Metrics Fan-in/fan-outFan-in is a measure of the number of functions that call some other function, say X Fan-out is a measure of the number of functions which are called by a function, say X. (See RFC) Cyclomatic complexity CC is a count of the number of test cases required to test comprehensively

March R. McFadyen4 Traditional Metrics Lines of Code LOC can be counted as lines (LOC) non-comment non-blank lines (NCNB) executable statements (EXEC) Note that NASA uses executable lines of code to evaluate size Comment percentage Calculated as the total number of comments divided by the {total lines of code less the number of blank lines}

March R. McFadyen5 Traditional Metrics Depth of conditional nesting Measure of the depth of nesting of IF statements in programs Fog indexMeasure of the average length of words and sentences in documents. The higher the value for the Fog index, the more difficult... Length of identifiers Measures average length of distinct identifiers

March R. McFadyen6 OO Metrics Weighted methods per class WMC is the number of methods included in a class weighted by the complexity of each method Response for a class RFC is a count of all methods that can be invoked in response to a message to an object of the class

March R. McFadyen7 OO Metrics Lack of cohesion of methods LOCM measures the dissimilarity of methods in a class. A highly cohesive module stands alone. Lack of cohesion increases complexity. Coupling between objects CBO is a count of the number of other classes to which a class is coupled. Measured by counting the number of distinct non-inheritance related class hierarchies on which a class depends

March R. McFadyen8 OO Metrics Depth of inheritance tree DIT is the maximum number of steps from the class node to the root of the tree Number of children NOC is the number of immediate subclasses subordinate to a class in the hierarchy Number of overriding operations Number of operations in a superclass that are overridden in a subclass

March R. McFadyen9 WMC Weighted methods per class WMC is the number of methods included in a class weighted by the complexity of each method How does one count this? a) simply count the number of methods, or, b) sum the complexities of the methods (complexity might be rated: 1 Simple, 2 Moderately complex, 3 Complex)

March R. McFadyen10 WMC Shows that most classes have less than 20 methods, … but some have over 200 methods.

March R. McFadyen11 RFC Response for a class RFC is a count of all methods that can be invoked in response to a message to an object of the class How does one count this? For a class, we count the number of distinct methods that can be invoked in response to a message, including all methods within the class hierarchy For a class, we count all messages that can be sent by all methods in the class

March R. McFadyen12 RFC In this case, about half the classes have an RFC <=20

March R. McFadyen13 LCOM Lack of cohesion of methods LOCM measures the dissimilarity of methods in a class. A highly cohesive module stands alone. Lack of cohesion increases complexity. How does one count this? We need a way of measuring cohesiveness (or not). First proposal: a) compute the average over all attributes in a class number of methods using the attribute total number of methods convert to a percentage and subtract from 100

March R. McFadyen14 LCOM Second proposal: b) for each method, create a set of the attributes it accesses. For each pair of methods, perform the intersection of attributes. If an intersection is not empty put the set in P; if it is empty put the set in Q. The measure is the difference in cardinalities of P and Q: LCOM = P - Qif P > Q otherwise LCOM = 0

March R. McFadyen15 LCOM

March R. McFadyen16 CBO Coupling between objects CBO is a count of the number of other classes to which a class is coupled. Measured by counting the number of distinct non-inheritance related class hierarchies on which a class depends How does one count this? count the number of distinct noninheritance-related class hierarchies on which a class depends

March R. McFadyen17 CBO A CBO value of zero corresponds to a class that is only coupled to others in its related inheritance hierarchy

March R. McFadyen18 DIT Depth of inheritance tree Most classes are at level 0 and 1 DIT is the maximum number of steps from the class node to the root of the tree

March R. McFadyen19 NOC Number of children NOC is the number of immediate subclasses subordinate to a class in the hierarchy How does one count this? the number of immediate subclasses subordinate to a class in the hierarchy

March R. McFadyen20 NOC One of these classes, at depth 3, has almost 40 children!

March R. McFadyen21 CC Cyclomatic complexity CC is a count of the number of test cases required to test comprehensively CC measures the amount of decision logic in a module. A value of 10 or less is the general recommendation. Formally, based on a program’s flowgraph, Cyclomatic complexity = number of edges – number of nodes + 2

March R. McFadyen22 CC Control flowgraphs describe the logic structure of software modules. A module corresponds to a single function or subroutine in typical languages, has a single entry and exit point, and is able to be used as a design component via a call/return mechanism. Each flowgraph consists of nodes and edges. nodes represent computational statements or expressions, edges represent transfer of control between nodes.

March R. McFadyen23 Flowgraph Construction - Sequence x=z y=7 y=10 Sequences are reducible to a single node: CC=?

March R. McFadyen24 Flowgraph Construction – If then if x>4 then x=z y=7 q=q*2 end if CC=

March R. McFadyen25 Flowgraph Construction – If Else if x>4 then x=z y=7 else y=10 end if CC=

March R. McFadyen26 Flowgraph Construction - While while x>0 do x=x/2 … end while CC=

March R. McFadyen27 Flowgraph Construction – Do Until Do … Read x Until x=0 CC=

March R. McFadyen28 Program FindMean (FILE ScoreFile) { float SumOfScores = 0.0; int NumberOfScores = 0; float Mean=0.0; float Score; Read(ScoreFile, Score); while (! EOF(ScoreFile) { if (Score > 0.0 ) { SumOfScores = SumOfScores + Score; NumberOfScores++; } Read(ScoreFile, Score); } /* Compute the mean and print the result */ if (NumberOfScores > 0) { Mean = SumOfScores / NumberOfScores; printf(“ The mean score is %f\n”, Mean); } else printf (“No scores found in file\n”); }

March R. McFadyen29 Flowgraph Cyclomatic complexity = CC = = 4 decision structures: one while one if then one if else

March R. McFadyen30 CC