Object Oriented Metrics. Impact on Software Quality

Similar documents
Technical Metrics for OO Systems

CHAPTER 4 HEURISTICS BASED ON OBJECT ORIENTED METRICS

Quantify the project. Better Estimates. Resolve Software crises

Research Article ISSN:

Object-oriented metrics 1

Object Oriented Measurement

Effective Modular Design

Measuring the quality of UML Designs

Introduction to software metics

Risk-based Object Oriented Testing

Reusability Metrics for Object-Oriented System: An Alternative Approach

CHAPTER 3 ROLE OF OBJECT-ORIENTED METRICS IN SOFTWARE MEASUREMENT

Metrics in assessing the quality and evolution of jedit

Towards Cohesion-based Metrics as Early Quality Indicators of Faulty Classes and Components

Application of Object Oriented Metrics to Java and C Sharp: Comparative Study

Software Design & Evolution. Lecture 04. You cannot control what you cannot measure. Metrics & Problem Detection. Michele Lanza

Object Oriented Design Metrics for Predicting Fault Proneness using Naïve Bayes and Random Forest

Investigation of Metrics for Object-Oriented Design Logical Stability

Principal Component Analysis of Lack of Cohesion in Methods (LCOM) metrics

Metrics and OO. SE 3S03 - Tutorial 12. Alicia Marinache. Week of Apr 04, Department of Computer Science McMaster University

Effectiveness of software metrics for object-oriented system

What are Metrics?! Functions, that assign a precise numerical value to. Detecting Design Problems using Metrics

Software metrics for Java and C++ practices. Référencement des métriques utiles à la caractérisation des pratiques sensibles pour Java et C++

Kostis Kapelonis Athens Greece, March 2010

CHAPTER 2 LITERATURE REVIEW

2IS55 Software Evolution. Software metrics (3) Alexander Serebrenik

Software Metrics for Package Remodularisation

Influence of Design Patterns Application on Quality of IT Solutions

2IS55 Software Evolution. Software metrics (2) Alexander Serebrenik

Design Quality Assessment in Practice

SOFTWARE ASSESSMENT USING OBJECT METRICS

Chapter 5 Object-Oriented Programming

Using Metrics To Manage Software Risks. 1. Introduction 2. Software Metrics 3. Case Study: Measuring Maintainability 4. Metrics and Quality

Moonzoo Kim CS Division of EECS Dept.

A Study of Software Metrics

An Object-Oriented Metrics Suite for Ada 95

Importance of Software Metrics to Quantify of Software Design and Source Code Quality

Analysis of Various Software Metrics Used To Detect Bad Smells

FOR0383 Software Quality Assurance

Chapter 8: Class and Method Design

How to Realization Architectural testing model using Measurement Metrics

Analysis of Reusability of Object-Oriented System using CK Metrics

EVALUATING IMPACT OF INHERITANCE ON OBJECT ORIENTED SOFTWARE METRICS

A Critical Analysis of Current OO Design Metrics

Object-Oriented Design Quality Models A Survey and Comparison

Quality Metrics Tool for Object Oriented Programming

Analysis of Object Oriented Metrics on a Java Application

Report and Opinion 2014;6(10) Measurement Of Software Complexity In Object Oriented Systems Abstract

ANALYSIS OF OBJECT ORIENTED SOFTWARE METRICS

Design Metrics for Object-Oriented Software Systems

Vragen. Intra-modular complexity measures. The uses relation. System structure: inter-module complexity

ISSN: [Gupta* et al., 6(5): May, 2017] Impact Factor: 4.116

By: Eng. Mohammed T. Abo Alroos

Restructuring. What is restructuring? Tudor Gîrba Reengineering life cycle. What? forward engineering. reverse engineering

J2EE Development Best Practices: Improving Code Quality

A Comparative Study on State Programming: Hierarchical State Machine (HSM) Pattern and State Pattern

Empirical Evaluation and Critical Review of Complexity Metrics for Software Components

Software Metrics and Problem Detection

Software Quality Estimation through Object Oriented Design Metrics

ISSN: ISO 9001:2008 Certified International Journal of Engineering and Innovative Technology (IJEIT) Volume 3, Issue 11, May 2014

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

METRIC ATTITUDE PLUG-IN FOR ECLIPSE USER GUIDE

Procedia Computer Science

1 Introduction. Abstract

Evaluation of a Business Application Framework Using Complexity and Functionality Metrics

CSE 70 Final Exam Fall 2009

Inheritance. EEC 521: Software Engineering. Dealing with Change. Polymorphism. Software Design. Changing requirements Code needs to be flexible

Quality measurement of programming examples. Extension for programming editor BlueJ

Enhancing Object Oriented Coupling Metrics w.r.t. Connectivity Patterns

Class Break Point Determination Using CK Metrics Thresholds

Static Metrics. Feature Brief

CHAPTER 5 GENERAL OOP CONCEPTS

Data Abstraction. Hwansoo Han

Effects of Dependency Injection on Maintainability. Kate Razina

Quality measurement of programming examples. Extension for programming editor BlueJ

Similar Characteristics of Internal Software Quality Attributes for Object-Oriented Open-Source Software Projects

International Journal of Software and Web Sciences (IJSWS)

Principles of Object-Oriented Design

Thresholds for Software Quality Metrics in Open Source Android Projects

Visualizing Software Metrics for increased Refactoring

Enhancing Mood Metrics Using Encapsulation

Tool support for software metrics calculation of Java projects

An Empirical Investigation of Inheritance Trends in Java OSS Evolution. by Emal Nasseri

Object interconnections

Software Metrics. Lines of Code

A Case Study on Quality Attribute Measurement using MARF and GIPSY

Design and code coupling assessment based on defects prediction. Part 1

Scanner - A tool for collecting object oriented software metrics from C++ class definitions

Object-Oriented Concepts and Design Principles

A Hierarchical Model for Object- Oriented Design Quality Assessment

REVERSE SOFTWARE ENGINEERING AND REENGINEERING TO DETECT PLAGIARISM IN JAVA PROGRAMS

Application of a Fuzzy Inference System to Measure Maintainability of Object-Oriented Software

Towards a Unified Source Code Measurement Framework Supporting Multiple Programming Languages

Factors Modulating Software Design Quality

Classes and Objects. Object Orientated Analysis and Design. Benjamin Kenwright

Inheritance and Polymorphism

INNOVATIVE ENGINEERING TECHNIQUE OF OBJECT ORIENTED SOFTWARE DEVELOPMENT

Analyzing Java Software by Combining Metrics and Program Visualization

Er. Himanshi Vashisht, Sanjay Bharadwaj, Sushma Sharma

ATL Transformation Example

Transcription:

Object Oriented Metrics Impact on Software Quality

Classic metrics Lines Of Code Function points Complexity Code coverage - testing Maintainability Index discussed later

Lines of Code KLOC = 1000 Lines Of Code Physical Logical Def: A line of code is any line of program text that is not a comment or blank line, regardless of the number of statements or fragments of statements on the line. This specifically includes all lines containing program headers, declarations, and executable and non-executable statements. [Conte ao-software Engineering Metrics and Models] Function points = measure of develop. resources Number of external inputs x 4 Number of external outputs x 5 Number of logical internal files x 10 Number of external interface files x 7 Number of external inquiries x 4 S.Motogna - Software Quality

McCabe, 1976 Where: Cyclomatic complexity CC = E - N + 2*P E = number of edges in the flow graph N = number of nodes in the flow graph P = number of nodes that have exit points Control flow graph: graph with: nodes = basic blocks edges correpsonding to all paths that may be traversed in a program during its execution

Object oriented (OO) metrics Metrics - Chidamber & Kemerer 1993 Available at: http://maisqual.squoring.com/wiki/images/5/5c/ch id_kem_metrics.pdf MOOD Abreu 1995 [Abreu, F. B. e., "The MOOD Metrics Set," presented at ECOOP '95 Workshop on Metrics, 1995.]

Classification [Abreu] 5 aspects: System Coupling Inheritance Class method

Classification [Marinescu - Object-Oriented Software Metrics] Available at: http://www2.informatik.huberlin.de/swt/intkoop/jcse/workshops/risan2 007/0206-Marinescu-jcse-metrics.pdf 4 aspects: Size & Structural Complexity Inheritance Coupling Cohesion

Useful for: Evaluate, predict, improve software quality Detecting design flaws

Weighted Methods Per Class (WMC) Definition: Consider a Class C1, with methods M1,... Mn that are defined in the class. Let c1,... cn be the complexity of the methods. Then :

Weighted Methods Per Class (WMC) Indicator for how much time and effort is required to develop and maintain the class. Higher values Þ higher impact on descendants Higher values Þ more application specific, low reusability & maintainability low values Þ greater polymorphism

Weighted Methods Per Class (WMC) Criterion: Î [1, 50] or max 10% of classes may have WMC over 25 Remark: counts Constructors and event handlers Property accessor (Get, Set, Let) Advice: Refactor classes with high WMC Impact: maintainability, reusability

Depth of Inheritance Tree (DIT) Definition: maximum length from the node to the root of the tree. measure of how many ancestor classes can potentially affect this class.

Depth of Inheritance Tree (DIT) Higher DIT Þ higher complexity + difficult to predict behavior + difficult to maintain But higher reusability Values: 10 Rec. 5 (RefactorIT & Visual Studio) In java min = 1 Advice: If 2 then poor OO design Not just per class, entire distribution

Number of children (NOC) Definition: Number of immediate sub-classes subordinated to a class in the class hierarchy. It is a measure of how many sub-classes are going to inherit the methods of the parent class.

Number of children (NOC) high NOC Þ High reuse of base class Base class may require more testing Improper abstraction of the parent class Misuse of sub-classing + high WMC Þ complexity at the top of the class hierarchy - poor design Upper part of class hierarchy higher NOC than lower part

Number of children (NOC) Advice: Î [0,10] (RefactorIT) ³ 10 => restructure class hierarchy

Coupling between Objects (CBO) CBO(c) = {d C {c} uses(c, d) or uses(d, c)} CBOʹ(c)= {d C ({c} Ancestors(c)) uses(c, d) or uses(d,c)} Where: item C: an OO software system Ancestors(c): generalizations of c uses(c, d) true if method (re)defined by d invoked by method of c

Coupling between Objects (CBO) through method calls, field accesses, inheritance, arguments, return types, and exceptions High CBO Þ Low modularity and reusability (independent classes - easier to reuse) Low maintainability High complexity Þ difficult testing

Coupling between Objects (CBO) Advice: If high CBO and high NOC re-evaluate design Used by senior designers and project managers to track whether the class hierarchy is losing its integrity whether different parts of a large system are developing unnecessary interconnections in inappropriate places.

Afferent Coupling (Ca) determines the number of classes and interfaces from other packages that depend on classes in the analyzed package indicator of the level of responsibility: If the package is relatively abstract then a large number of incoming dependencies is acceptable and not if the package is more concrete. Indicator of maintainability and testability

Efferent Coupling (Ce) Determines the number of other packages that the classes in the package depend upon is an indicator of the package's independence. High Ce: package is unfocussed unstable since it depends on the stability of all the types to which it is coupled. max 20 (RefactorIT) recommends an upper limit of 20. Advice: extract classes from the original class so the class is decomposed into smaller classes.

Afferent Coupling measure of how many other classes use the specific class Efferent Coupling measure of how many different classes are used by the specific class class Foo { Qclass q; } class Bar { Qclass q; } class Qclass { //... } Ce(Foo) = Ce(Bar) = 1 Ca(Qclass) = 2

Lack of Cohesion of Methods (LCOM) LCOM1, LCOM2, LCOM3 and LCOM4 (Hitz & Montazeri) Definition: Let C be a class IC is the set of instance variables of C MC is the set of methods of C GC is a graph with vertices V = MC and edges E (V V) where (m, n) E m and n share at least one common instance variable LCOM = number of connected subgraphs

Lack of Cohesion of Methods (LCOM4) Methods a and b are related if: -they both access the same class-level variable - a calls b, or b calls a. LCOM4=1 - cohesive class =>"good" class LCOM4>=2 problem => split class into smaller classes LCOM4=0 - no methods in a class => "bad" class

Lack of Cohesion of Methods (LCOM4) Cohesiveness promotes encapsulation Lack of cohesion - split into two or more subclasses Any measure of disparateness of methods helps identify flaws in the design of classes Low cohesion increases complexity and maintainability

TCC (Tight Class Cohesion) measures the cohesion of a class: the relative number of method-pairs that access an attribute of the class Example: TCC = 2/10, resp. 4/10 TCC [0..1] Higher TCC => higher cohesion LCC Loose Class Cohesion

MOOD and MOOD2 metrics [F. Brito & Abreu] 1. MHF - Method Hiding Factor 2. AHF - Attribute Hiding Factor 3. MIF - Method Inheritance Factor 4. AIF - Attribute Inheritance Factor 5. PF - Polymorphism Factor 6. CF - Coupling Factor MOOD2 extension of MOOD

Law of Demeter proposed at Northeastern University in 1987 Form of loose coupling Summary: Each unit should have only limited knowledge about other units: only units "closely" related to the current unit. Each unit should only talk to its friends; don't talk to strangers. Only talk to your immediate friends. "Only talk to your friends" => "Only talk to your friends who share your concerns"

Law of Demeter Objects should only collaborate with their nearest neighbours - the less they depend on the interfaces of friends of a friend, the less reasons they might have to have to change avoiding long navigations and deferring knowledge of interactions with objects that aren t directly related to your nearest neighbours

Law of Demeter Refactor

Law of Demeter

Law of Demeter Talk by Ben Orenstein at RailsConf 2013 provides a very good visualization of the Law of Demeter http://www.youtube.com/watch?v=l9jxh7jpjr4 Further reading: D.Bock - The Paperboy, The Wallet, and The Law Of Demeter

OO metrics Tools Metrics plugin Eclipse IntelliJ metrics plugin Ndepend + Metrics -.NET PhpMetrics Java