Introduction to software metics

Similar documents
Technical Metrics for OO Systems

Object Oriented Metrics. Impact on Software Quality

CHAPTER 4 HEURISTICS BASED ON OBJECT ORIENTED METRICS

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

Effectiveness of software metrics for object-oriented system

Investigation of Metrics for Object-Oriented Design Logical Stability

Quantify the project. Better Estimates. Resolve Software crises

SNS College of Technology, Coimbatore, India

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

Risk-based Object Oriented Testing

UML and Design Patterns Prof. Dr. Eric Dubuis, V. June Engineering and Information Technology. On Package Design

Research Article ISSN:

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

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

Object Oriented Measurement

Software Metrics. Lines of Code

Dependency Inversion Principle (DIP) Package Design: Coupling Principles

Effective Modular Design

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

Measuring the quality of UML Designs

An Empirical Study on Object-Oriented Metrics

Analysis of Reusability of Object-Oriented System using CK Metrics

How do we measure product and project progress?? Why is software incomparable to traditional quality of manufactured goods?

Metrics in assessing the quality and evolution of jedit

Kostis Kapelonis Athens Greece, March 2010

Reusability Metrics for Object-Oriented System: An Alternative Approach

ACICE-2013 ISSN: ; e-issn

CHAPTER 2 LITERATURE REVIEW

A New Weighted Composite Complexity Measure for Object-Oriented Systems

Empirical Evaluation and Critical Review of Complexity Metrics for Software Components

A Study of Software Metrics

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

Software Metrics for Package Remodularisation

Influence of Design Patterns Application on Quality of IT Solutions

Taxonomy Dimensions of Complexity Metrics

SOFTWARE ASSESSMENT USING OBJECT METRICS

Evaluation of a Business Application Framework Using Complexity and Functionality Metrics

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

USING COMPLEXITY, COUPLING, AND COHESION METRICS AS EARLY INDICATORS OF VULNERABILITIES

Tool support for software metrics calculation of Java projects

Visualizing Software Metrics for increased Refactoring

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

Er. Himanshi Vashisht, Sanjay Bharadwaj, Sushma Sharma

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

EVALUATING IMPACT OF INHERITANCE ON OBJECT ORIENTED SOFTWARE METRICS

Static Metrics. Feature Brief

FOR0383 Software Quality Assurance

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

Measuring Complexity

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

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

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

Maintainability and Agile development. Author: Mika Mäntylä

Can Complexity, Coupling, and Cohesion Metrics be Used as Early Indicators of Vulnerabilities?

Fault-Proneness Estimation and Java Migration: A Preliminary Case Study

1 Introduction. Abstract

CHAPTER 4 OBJECT ORIENTED COMPLEXITY METRICS MODEL

Object-oriented metrics 1

J2EE Development Best Practices: Improving Code Quality

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

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

Class Break Point Determination Using CK Metrics Thresholds

Principles of Object-Oriented Design

Effects of Dependency Injection on Maintainability. Kate Razina

Software metrics for policy-driven software development life cycle automation

Quality Metrics Tool for Object Oriented Programming

2IS55 Software Evolution. Software metrics. Alexander Serebrenik

Theoretical Validation of Inheritance Metrics for Object-Oriented Design against Briand s Property

A Critical Analysis of Current OO Design Metrics

Prediction of Software Readiness Using Neural Network

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

Exploring Efficient Ways of Distributing Code Quality Metrics in Cloud

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

(S)LOC Count Evolution for Selected OSS Projects. Tik Report 315

Software Testing: A Craftsman s Approach, 4 th Edition. Chapter 16 Software Complexity

An Object-Oriented Metrics Suite for Ada 95

Software Testing 2. OOD and Testability. White box vs Black box Testing. Software Testing 2 Semester 1, 2006

Mixing SNA and Classical Software Metrics for Sub-Projects Analysis.

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

Change and Fault Proneness in an Object-Oriented Software System

AUTOMATION AND EVALUATION OF SOFTWARE FAULT PREDICTION

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

Software Metrics and Problem Detection

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

Design Quality Assessment in Practice

Software Quality Estimation through Object Oriented Design Metrics

Moonzoo Kim CS Division of EECS Dept.

How to Realization Architectural testing model using Measurement Metrics

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

A TAXONOMY OF MODULAR GRIME IN DESIGN PATTERNS. Travis Steven Schanz. A thesis submitted in partial fulfillment of the requirements for the degree

Plan. Design principles: laughing in the face of change. What kind of change? What are we trying to achieve?

Stability. Introduction

MEASURING AND QUANTIFYING WEB APPLICATION DESIGN

Research Article An Empirical Study of the Effect of Power Law Distribution on the Interpretation of OO Metrics

Factors Modulating Software Design Quality

Software Design Fundamentals. CSCE Lecture 11-09/27/2016

Towards the re-usability of software metric definitions at the meta level

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

INNOVATIVE ENGINEERING TECHNIQUE OF OBJECT ORIENTED SOFTWARE DEVELOPMENT

LEXIMET: A Lexical Analyzer Generator including McCabe's Metrics.

Transcription:

Introduction to software metics Alexander Voigt Version_05_21 Technische Universität Dresden Institut für Kern- und Teilchenphysik /01234/546 78994:!"##$%&'$()*+,%&-,,$)*.$ IKTP Computing Kaffee 12 December 2011 Version_05_20 /01234/546 78994:!"##$%&'$()*+,%&-,,$)*.$ Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 1 / 18

Content 1 Why software metrics? 2 Simple/ naive metrics 3 Procedural software metrics McCabe s cyclomatic complexity Information flow complexity 4 Object oriented software metrics Weighted methods per class Depth of inheritance tree Number of children Coupling between objects 5 Software package metrics Motivation The main sequence Cohesion and categories Metric definitions 6 Recommendations for metric values in C++ Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 2 / 18

Why software metrics? software metric software metric = a measure of a property of a piece of software Goal: objective, reproducible and quantifiable measurements of software for schedule planning cost estimation quality testing software debugging software performance optimization Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 3 / 18

Simple/ naive metrics Number of lines of code (SLOC) Number of lines of comments (NLOCom) Number of lines of comments per SLOC Number of classes and interfaces Program execution time Program binary size Bugs per line of code Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 4 / 18

Number of lines of code free SLOC counter (GNU GPL): sloccount 1 ~/ tmva / $ sloccount src /*. cxx inc / TMVA /*. h 2 Total Physical Source Lines of Code ( SLOC ) = 48,883 3 Development Effort Estimate, Person - Years ( Person - Months ) = 11.88 (142.50) 4 ( Basic COCOMO model, Person - Months = 2.4 * ( KSLOC **1.05) ) 5 Schedule Estimate, Years ( Months ) = 1.37 (16.46) 6 ( Basic COCOMO model, Months = 2.5 * ( person - months **0.38) ) 7 Estimated Average Number of Developers ( Effort / Schedule ) = 8.66 8 Total Estimated Cost to Develop = $ 1,604,196 9 ( average salary = $56,286/ year, overhead = 2.40). Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 5 / 18

Procedural software metrics McCabe s cyclomatic complexity McCabe s Cyclomatic Complexity (MVG) [McC76] = the number of linearly independent paths through the source code Example: 1 unsigned int factorial ( unsigned int n) 2 { 3 if ( n <= 1) return 1; 4 unsigned int result = 1; 5 while (n > 1) { 6 result *= n; 7 --n; 8 } 9 return result ; 10 } In this example MVG = 3, see next slide. Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 6 / 18

Procedural software metrics McCabe s cyclomatic complexity no start yes n <= 1 return 1 no result = 1 n > 1 yes result *= n --n return result end McCabe s cyclomatic complexity M is defined as where M := E N + 2P N = number of nodes, E = number of edges, P = number of connected components in the corresponding control flow graph. In this example: E = 10, N = 9, P = 1 M = 3 Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 7 / 18

Procedural software metrics Information flow complexity Information flow complexity (IFC) (defined by IEEE 982.2): IFC := (fanin fanout) 2 fanin = local flows into a procedure + number of data structures from which the procedure retrieves data fanout = local flows from a procedure + number of data structures that the procedure updates Example: 1 int main () 2 { 3 unsigned number = 5; 4 cout << number << "! = " // fanout = 1 5 << factorial ( number ) // fanin = 1 6 << endl ; 7 return 0; 8 } IFC = (1 1) 2 = 1 Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 8 / 18

Object oriented software metrics Weighted methods per class (WMC) Weighted methods per class (WMC) Variants: WMC1: count 1 for each function WMCv: count 1 for functions accessible to other modules, 0 for private functions Example: 1 class A { 2 public : 3 method1 () {} 4 method2 () {} 5 private : 6 method3 () {} 7 method4 () {} 8 }; WMC1 = 4 WMCv = 2 Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 9 / 18

Object oriented software metrics Depth of inheritance tree (DIT) Depth of inheritance tree (DIT) = The length of the longest path of inheritance ending at the current module. The deeper the inheritance tree for a module, the harder it may be to predict its behaviour. On the other hand, increasing depth gives the potential of greater reuse by the current module of behaviour defined for ancestor classes. Base Derived1 Derived2 Derived3 Derived11 Derived12 DIT(Base) = 0, DIT(Derived1) = 1, DIT(Derived11) = 2 Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 10 / 18

Object oriented software metrics Number of children (NOC) Number of children (NOC) = The number of modules which inherit directly from the current module. Moderate values of this measure indicate scope for reuse, however high values may indicate an inappropriate abstraction in the design. Base Derived1 Derived2 Derived3 Derived11 Derived12 NOC(Base) = 3 NOC(Derived1) = 2 NOC(Derived2) = 0 Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 11 / 18

Object oriented software metrics Coupling between objects (CBO) Coupling between objects (CBO) = The number of other modules which are coupled to the current module either as a client or a supplier. Excessive coupling indicates weakness of module encapsulation and may inhibit reuse. A B C D CBO(A) = 2 CBO(B) = 1 CBO(C) = 1 CBO(D) = 0 Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 12 / 18

Software package metrics motivation some OO design goals: extend/ alter behaviour without modification of existing code modularity can be achieved by designing classes such that details depend on generalities generalities depend on nothing there are (approximately) two types of classes: 1 abstract base classes many classes depend on them very responsible (if they change, many other classes need to be changed as well) unlikely to change since they don t depend on anything very stable 2 concrete classes with implementation details very few classes depend on them irresponsible likely to change instable Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 13 / 18

Software package metrics the main sequence In an optimal design classes/ categories lie on the "main sequence": Architectural Structures Abstractness Main Sequence Implementation Details Instability Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 14 / 18

Software package metrics Definition Let M = {a 1,..., a N } be a set of classes. Let R be the number of class relationships within a subset O M. Then the cohesion H(O) is defined as (see [Mar95]) Definition H(O) := R + 1 N A category C is a subset C M with maximum cohesion and minimum relations to M\C. C M\C Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 15 / 18

Software package metrics Definition Let C M be a category. Afferent coupling Efferent coupling Ca(C) := #of classes a i M\C that depend on C Ce(C) := #of dependencies on classes a i M\C Instability Ce I(C) := [0, 1] Ce + Ca Abstractness #of abstract classes A(C) := [0, 1] #of classes Distance from D (C) := A + I 1 [0, 1] Main Sequence Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 16 / 18

Recommendations for metric values in C++ metric recommended value reference SLOC per function 25 "25 lines 80 columns" rule NLOCom / SLOC 1 Arnd Bäcker in Computational Physics MVG 10 (simple program) [McC76] IFC? WMC 7 [McC05] DIT 3 [CK94] NOC 15 [CK94] CBO 10 [CK94] Cohesion H(C) > 0.75 [Mar95] Distance D (C) < 0.4 [Mar95] Program complexity from McCabe s cyclomatic complexity: M 10 simple program 10 < M 20 more complex program 20 < M 40 very complex program M > 40 untestable program Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 17 / 18

Literature S.R. Chidamber and C.F. Kemerer. A metrics suite for object oriented design. IEEE Transactions on Software Engineering, 20:6:476 493, 1994. Robert C. Martin. Designing Object-Oriented C++ Applications Using The Booch Method. Prentice-Hall, 1st edition, 1995. Thomas J. McCabe. A complexity measure. In Proceedings of the 2nd international conference on Software engineering, ICSE 76, pages 407, Los Alamitos, CA, USA, 1976. IEEE Computer Society Press. Steve McConnell. Code Complete. Microsoft Press, Deutschland, 1st edition, 2005. Alexander Voigt (TU Dresden) Introduction to software metics IKTP Computing Kaffee 12.12.11 18 / 18