Object Oriented Metrics

Slides:



Advertisements
Similar presentations
SPEC Workshop 2008 Laboratory for Computer Architecture1/27/2008 On the Object Orientedness of C++ programs in SPEC CPU 2006 Ciji Isen & Lizy K. John University.
Advertisements

Software Metrics for Object Oriented Design
Software Metrics Software Engineering.
Refactoring Overview  What is refactoring?  What are four good reasons to refactor?  When should you refactor?  What is a bad smell (relative to refactoring.
Figures – Chapter 24.
Metrics for Object Oriented Design Shyam R. Chidamber Chris F. Kemerer Presented by Ambikadevi Damodaran.
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.
Nov R. McFadyen1 Metrics Fan-in/fan-out Lines of code Cyclomatic complexity* Comment percentage Length of identifiers Depth of conditional.
Object Oriented Design
Page 1 Building Reliable Component-based Systems Chapter 7 - Role-Based Component Engineering Chapter 7 Role-Based Component Engineering.
Object-Oriented Metrics. Characteristics of OO ● Localization ● Encapsulation ● Information hiding ● Inheritence ● Object abstraction.
Design Metrics Software Engineering Fall 2003 Aditya P. Mathur Last update: October 28, 2003.
© S. Demeyer, S. Ducasse, O. Nierstrasz Duplication.1 7. Problem Detection Metrics  Software quality  Analyzing trends Duplicated Code  Detection techniques.
Object-Oriented Metrics
March R. McFadyen1 Software Metrics Software metrics help evaluate development and testing efforts needed, understandability, maintainability.
1 Complexity metrics  measure certain aspects of the software (lines of code, # of if-statements, depth of nesting, …)  use these numbers as a criterion.
PVK-Ht061 Contents Introduction Requirements Engineering Project Management Software Design Detailed Design and Coding Quality Assurance Maintenance.
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.
Chapter 9: Software Metrics
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.
Lecture 17 Software Metrics
Chidamber & Kemerer Suite of 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.
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.
Product Metrics An overview. What are metrics? “ A quantitative measure of the degree to which a system, component, or process possesses a given attribute.”
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.
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 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.
Lecture 12 March 16, The Scope of a Variable What if there are two variables with the same name? –A local or block-local variable can have the same.
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,
Chapter 8 Inheritance. 2  Review of class relationships  Uses – One class uses the services of another class, either by making objects of that class.
Object Oriented Programming
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
Coming up: Inheritance
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.
Rohini Sharma Roll No. RA1809A01 Regd. No M.Tech.(CSE) Part Time 3 rd Semester.
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.
Design Metrics CS 406 Software Engineering I Fall 2001 Aditya P. Mathur Last update: October 23, 2001.
Inheritance a subclass extends the functionality of a superclass a subclass inherits all the functionality of a superclass don't reinvent the wheel – "stand.
Object Oriented Metrics
A Hierarchical Model for Object-Oriented Design Quality Assessment
Software Metrics 1.
Course Notes Set 12: Object-Oriented Metrics
Design Characteristics and Metrics
Towards a Multi-paradigm Complexity Measure
Phil Tayco Slide version 1.0 Created Nov 6, 2017
Object-Oriented Metrics
CS427: Software Engineering I
Design Metrics Software Engineering Fall 2003
Design Metrics Software Engineering Fall 2003
Mei-Huei Tang October 25, 2000 Computer Science Department SUNY Albany
CS223: Software Engineering
Software Metrics SAD ::: Fall 2015 Sabbir Muhammad Saleh.
Chapter 8: Design: Characteristics and Metrics
Presentation transcript:

Object Oriented Metrics Group 5: Luke Swanson, Paul DeBruyne, Alex Martin, Erik Matchette, Paul Mauer

Overview

Overview: Object-Oriented Metrics OO Metrics: What are they? Quantitative measurement of the qualities of OO design Coupling Cohesion Encapsulation Inheritance Complexity Goal: Measure the effectiveness of OO techniques in a design

Metrics

Depth of Inheritance Tree - Overview Measures the maximum length from a node to the root (base class) Three assumption about DIT: The deeper a class in the hierarchy, the greater the number of methods it will probably inherit which makes it harder to predict its behavior. Deeper trees involve greater design complexity since more classes and methods are involved. Deeper classes in the tree have a greater potential for reusing inherited methods. Typically upper limit is 5-6

Depth of Inheritance Tree - Example B C D B C D E F E F DIT = 3 Bottom Heavy DIT = 2 Balanced tree G H I J

Number of Children - Overview Is a measure of the number of immediate subclasses of a class in a hierarchy Viewpoints: The more children the more reuse More children might mean improper abstraction More children might indicate greater importance

Number of Children - Example A has 3 children C has none

Number of Operations Overridden (NOO) Number of inherited operations that are redefined by the class A large number for NOO indicates possible problems with the design Poor abstraction in inheritance hierarchy Implies too big a difference with the parent class → inheritance then makes less sense A class which inherits services must use them with a minimum number of modifications

Number of Operations Overridden (NOO) - Example class ParentClass { int x; int getResult() { return x; } } class ChildClass extends ParentClass { int y; int getResult() { return x + y; } } 1

Number of Operations Added (NOA) The number of operations added by a subclass As operations are added it moves further away from the superclass As depth increases, NOA should decrease

Number of Operations Added (NOA) - Example class ParentClass { int x, y, z; int getResult() { return x; } } class ChildClass1 extends ParentClass { int doSomething1() { return x + y; } int doSomething2() { return x + z; } } class ChildClass2 extends ChildClass1 { int doSomething3() { return y + z; } } 1 2

Class Size (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

Class Size (CS) - Example class ParentClass { int x, y, z; int getResult() { return x; } } class ChildClass1 extends ParentClass { int doSomething1() { return x + y; } int doSomething2() { return x + z; } } class ChildClass2 extends ChildClass1 { int doSomething3() { return y + z; } } 7 4 6

Method Inheritance Factor - Overview System level metric - measures how many methods in a system are inherited, and how many are overridden Ratio of the sum of inherited methods in all classes of the system to the total number of methods available for all classes Expressed as a value between 0 and 1, where 0 means no inherited methods are used, and 1 means all methods are inherited A Method Inheritance Factor between 0.2 and 0.8 is ideal for increased reliability and reduced testing effort

Method Inheritance Factor - Formula n = the total number of classes in the system Mi(Ci) = the number of methods inherited but not overwritten in class Ci Ma(Ci) = the number of methods that can be invoked in class Ci (includes inherited methods, overridden methods, new methods)

Method Inheritance Factor - Demonstration Shape Mi = 0 Ma = 6 Triangle Mi = 5 Ma = 9 Rectangle Mi = 5 Ma = 6

Polymorphism Factor - Overview Measures the degree of method overriding in a class inheritance tree Ratio of the number of method overrides over the maximum number of possible method overrides Expressed as a value between 0 and 1, where 0 means no overridden methods are used, and 1 means all methods are overridden

Polymorphism Factor - Formula TC = total number of classes in the class hierarchy Mo(Cj) = Number of overriding methods of class Cj Mn(Ci) = Number of new methods of class Ci DC(Ci) = Number of descendant classes of class Ci

Polymorphism Factor - Demonstration Shape Mo = 0 Mn = 6 Dc = 2 Triangle Mo = 1 Mn = 3 Dc = 0 Rectangle Mo = 1 Mn = 0 Dc = 0

Weighted Methods per Class Use another measure of complexity to determine overall class difficulty. Examples: Halstead’s complexity metrics (length, vocabulary, volume, etc). McCabe’s graph-based metrics. Complexity of all class methods is summed to obtain final complexity value. Equation: 𝛴ci = WMC ci is complexity of ith method.

Weighted Methods per Class - Example Using McCabe’s cyclomatic complexity. Class: Vector Method: Insert Remove Sort isEmpty Clear Find Complexity: 3 2 4 1

Weighted Methods per Class - Example Using McCabe’s cyclomatic complexity. Class: Vector Class complexity: WMC = 3 + 2 + 4 + 2 + 1 + 3 = ? Method: Insert Remove Sort isEmpty Clear Find Complexity: 3 2 4 1

Weighted Methods per Class - Example Using McCabe’s cyclomatic complexity. Class: Vector Class complexity: WMC = 3 + 2 + 4 + 2 + 1 + 3 = 15 Method: Insert Remove Sort isEmpty Clear Find Complexity: 3 2 4 1

Weighted Methods per Class Indicates general level of effort needed to develop/maintain the class. Less useful for small systems, becomes more useful for deep inheritance trees. High complexity classes can lead to high difficulty maintaining subclasses.

Response for a Class Equation: RS = Mc ∪ Me; |RS| = RFC. Number of methods that may be called in response to a class’s actions. To find RFC: Determine all external functions called by class methods. Take the union of that set and the set of class methods, called the response set (RS). RFC is simply the size of RS. Equation: RS = Mc ∪ Me; |RS| = RFC. Mc is set of class methods, Me is set of external methods called.

Response for a Class - Example List of objects in a game. Class: ObjectList Method: Insert Remove Move isEmpty Clear Find Show External Calls: ~object move equals draw

Response for a Class - Example List of objects in a game. Class: ObjectList Mc = {Insert, Remove, Move, isEmpty, Clear, Find, Show} Method: Insert Remove Move isEmpty Clear Find Show External Calls: ~object move equals draw

Response for a Class - Example List of objects in a game. Class: ObjectList Mc = {Insert, Remove, Move, isEmpty, Clear, Find, Show} Me = {~object, move, equals, draw} Method: Insert Remove Move isEmpty Clear Find Show External Calls: ~object move equals draw

Response for a Class - Example List of objects in a game. Class: ObjectList Mc = {Insert, Remove, Move, isEmpty, Clear, Find, Show} Me = {~object, move, equals, draw} RS = {Insert, Remove, Move, isEmpty, Clear, Find, Show, ~object, move, equals, draw} Method: Insert Remove Move isEmpty Clear Find Show External Calls: ~object move equals draw

Response for a Class - Example List of objects in a game. Class: ObjectList RS = {Insert, Remove, Move, isEmpty, Clear, Find, Show, ~object, move, equals, draw} RFC = |RS| = ? Method: Insert Remove Move isEmpty Clear Find Show External Calls: ~object move equals draw

Response for a Class - Example List of objects in a game. Class: ObjectList RS = {Insert, Remove, Move, isEmpty, Clear, Find, Show, ~object, move, equals, draw} RFC = |RS| = 11 Method: Insert Remove Move isEmpty Clear Find Show External Calls: ~object move equals draw

Response for a Class May be seen as a measure of object cohesion and coupling (or lack of). High RFC could indicate high coupling, or low cohesion. Low RFC may indicate opposite. Not very specific, however. High response for a class may lead to: More extensive test sets. More difficulty in understanding class. Less reusability. More time and effort needed to fix.

Coupling between Object Classes (CBO) Definition: The number of classes to which a class is coupled with Per class basis Coupling: method uses methods/instance variables of another class Goal: Lower CBO the Better Coupling is best kept to a minimum Promotes modular design Reuse Easier Maintenance

Coupling between Object Classes (CBO) Example

Lack of Cohesion in Methods (LCOM) Definition: # of not connected method pairs in a class Connected: methods in a class reference a same instance variable(s) Shows cohesion: operate on same data Per class basis Goal: LCOM4 = 1 Represents a cohesive class

LCOM4 Example

Questions?