Chap 4. Using Metrics To Manage Software Risks



Similar documents
Definitions. Software Metrics. Why Measure Software? Example Metrics. Software Engineering. Determine quality of the current product or process

Percerons: A web-service suite that enhance software development process

EVALUATING METRICS AT CLASS AND METHOD LEVEL FOR JAVA PROGRAMS USING KNOWLEDGE BASED SYSTEMS

Chapter 24 - Quality Management. Lecture 1. Chapter 24 Quality management

Object Oriented Design

Baseline Code Analysis Using McCabe IQ

Quality Analysis with Metrics

How To Calculate Class Cohesion

EPL603 Topics in Software Engineering

Quality prediction model for object oriented software using UML metrics

Design methods. List of possible design methods. Functional decomposition. Data flow design. Functional decomposition. Data Flow Design (SA/SD)

II. TYPES OF LEVEL A.

Vragen en opdracht. Complexity. Modularity. Intra-modular complexity measures

Synopsis: Title: Software Quality. Theme: Information Systems. Project Term: 9th semester, fall Project Group: sw907e13

Unit 11: Software Metrics

Mining Metrics to Predict Component Failures

Research Paper. (Received 25 August 2009; Accepted 31 December 2009) 1. Introduction

Karunya University Dept. of Information Technology

Using Code Quality Metrics in Management of Outsourced Development and Maintenance

Programming by Contract vs. Defensive Programming: A Comparison of Run-time Performance and Complexity

Evaluating the Relevance of Prevailing Software Metrics to Address Issue of Security Implementation in SDLC

How Designs Differ By: Rebecca J. Wirfs-Brock

Time evolution and distribution analysis of software bugs from a complex network perspective

Detecting Defects in Object-Oriented Designs: Using Reading Techniques to Increase Software Quality

International Journal of Advanced Research in Computer Science and Software Engineering

Software Defect Prediction Tool based on Neural Network

Empirical study of software quality evolution in open source projects using agile practices

Using Eclipse CDT/PTP for Static Analysis

Analysis Of Source Lines Of Code(SLOC) Metric

Open Source Software: How Can Design Metrics Facilitate Architecture Recovery?

Quantitative Evaluation of Software Quality Metrics in Open-Source Projects

Research Article Predicting Software Projects Cost Estimation Based on Mining Historical Data

Analyzing Java Software by Combining Metrics and Program Visualization

Quality Management. Objectives

Quality Management. Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 27 Slide 1

Assessing Internal Software Quality Attributes of the Object-Oriented and Service-Oriented Software Development Paradigms: A Comparative Study

Quality Management. Managing the quality of the software process and products

Quality Management. Objectives. Topics covered. Process and product quality Quality assurance and standards Quality planning Quality control

Software Metrics. Lord Kelvin, a physicist. George Miller, a psychologist

1 White-Box Testing by Stubs and Drivers

APPROACHES TO SOFTWARE TESTING PROGRAM VERIFICATION AND VALIDATION

Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur

Unit Test Case Design Metrics in Test Driven Development

Measuring Software Complexity to Target Risky Modules in Autonomous Vehicle Systems

A COMPARATIVE STUDY OF VARIOUS SOFTWARE DEVELOPMENT METHODS AND THE SOFTWARE METRICS USED TO MEASURE THE COMPLEXITY OF THE SOFTWARE

Quality Management. What is quality? Managing the quality of the software process and products ISO 9000

Keywords Class level metrics, Complexity, SDLC, Hybrid Model, Testability

Software Engineering Introduction & Background. Complaints. General Problems. Department of Computer Science Kent State University

Complexity Analysis of Simulink Models to improve the Quality of Outsourcing in an Automotive Company. Jeevan Prabhu August 2010

Software Metrics in Static Program Analysis

PREDICTIVE TECHNIQUES IN SOFTWARE ENGINEERING : APPLICATION IN SOFTWARE TESTING

Software Testing & Analysis (F22ST3): Static Analysis Techniques 2. Andrew Ireland

A Comprehensive Assessment of Object-Oriented Software Systems Using Metrics Approach

Analysis and Evaluation of Quality Metrics in Software Engineering

WESTMORELAND COUNTY PUBLIC SCHOOLS Integrated Instructional Pacing Guide and Checklist Computer Math

Fault Prediction Using Statistical and Machine Learning Methods for Improving Software Quality

Software Development: The Waterfall Model

Design and Code Complexity Metrics for OO Classes. Letha Etzkorn, Jagdish Bansiya, and Carl Davis. The University of Alabama in Huntsville

Why? A central concept in Computer Science. Algorithms are ubiquitous.

THE EFFECT OF SOFTWARE DESIGN PATTERNS ON OBJECT-ORIENTED SOFTWARE QUALITY AND MAINTAINABILITY

How To Validate An Isos 9126 Quality Model

CSC 408F/CSC2105F Lecture Notes

Data Structures and Algorithms Written Examination

The role of Software Metrics on Software Development Life Cycle

Analysis / Design. Traditional Development. Process models. Common Methodologies. Common Approach. Analysis: DFD. Traditional Software Development 1

CS314: Course Summary

Object Oriented Software Design

Predicting Class Testability using Object-Oriented Metrics

A methodology for measuring software development productivity using Eclipse IDE

Computing Concepts with Java Essentials

Software Quality Management

Object Oriented Software Design

1. What are Data Structures? Introduction to Data Structures. 2. What will we Study? CITS2200 Data Structures and Algorithms

SYSM 6304: Risk and Decision Analysis Lecture 5: Methods of Risk Analysis

Formal Software Testing. Terri Grenda, CSTE IV&V Testing Solutions, LLC

EVALUATION. WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration COPY. Developer

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.

Software Engineering

AN EMPIRICAL REVIEW ON FACTORS AFFECTING REUSABILITY OF PROGRAMS IN SOFTWARE ENGINEERING

Génie Logiciel et Gestion de Projets. Evolution

The Concern-Oriented Software Architecture Analysis Method

Supporting Workflow Overview. CSC532 Fall06

Program Understanding in Software Engineering

CS 1632 SOFTWARE QUALITY ASSURANCE. 2 Marks. Sample Questions and Answers

A Business Process Driven Approach for Generating Software Modules

Manufacturing View. User View. Product View. User View Models. Product View Models

IJCSMS International Journal of Computer Science & Management Studies, Special Issue of Vol. 12, June 2012 ISSN (Online):

ESTIMATING COMPLEXITY OF A SOFTWARE CODE

Transcription:

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

. Introduction Definition Measurement is the process by which numbers or symbols are assigned to attributes of entities in the real world so as to describe them according to specified rules. There are two broad use of measurement: assessment and prediction: Predictive measurement of some attribute A relies on a mathematical model relating A to some existing measures of attributes A,, A n. Assessment is more straightforward and relies on the current status of the attribute. There are 3 classes of software metrics: process, product, and project Process metrics: measure process effectiveness; Example: defect removal effectiveness. Product metrics: measure product characteristics such as size, cost, defect count etc. Project metrics: used to keep track of project execution; Examples: development time, development effort, productivity etc. 2

Software metrics provide a quantitative vehicle for evaluating and managing quality factors and risks related to a given software product. The software artifacts concerned by metrics include analysis, and design models, as well as program code. Metrics can be used at early stages as leading quality indicators of the software architecture design. They can also be used to drive an iterative design process (such as the Rational Unified Process). Metrics may be collected either dynamically or statically. Dynamic metrics require execution of the software system, which restrict their applicability to later phases of the development. Static metrics, in contrast can be collected and used at early stages of the design. 3

2. Software Measurement Concepts Measurement always targets specific software attribute or concept: Examples: complexity, cohesion, coupling, size, time, effort, maintainability etc. In software measurement studies, a distinction is made between internal and external attributes: Internal attributes: are those which can be measured purely in terms of the product, process, or project itself. Examples: size for product and elapsed time for process. External attributes: are those which can only be measured with respect to how the product, process, or project relates to other entities in its environment. Examples: reliability for product and productivity for project (e.g., people). Software Managers and Users would like to measure and predict external attributes. External attributes are easy to interpret but hard to measure directly, while internal attributes are hard to interpret but relatively easy to collect directly. 4

In practice, measurement of external attributes are derived indirectly from internal (attributes) measures, through correlation or statistical analysis such as regression or Bayesian probabilistic models. Example: Product Cost = f(effort, time); Effort (person/month)= g(size) 5

External Maintainability Reliability Usability Performance Internal Number of procedure parameters Cyclomatic complexity Program size (in lines of code) Number of error messages Length of user manual Number of daily requests received Number of daily requests processed 6

3. Case Study: Measuring Maintainability Important aspects of maintainability include understandability, flexibility, reusability, and testability. Complex code is difficult to understand, and thereby to maintain and evolve. Complex code increases the cost of testing, because the likelihood of faults is higher. Complexity is mastered by applying the principle of divide and conquer, which typically underlies another common design principle, namely modular design. Good modular design requires high cohesion of modules, and less coupling between them. Less cohesion means more complexity. Strong coupling means reduced reusability. Several software product metrics have been proposed to evaluate the complexity factors that affect the creation, comprehension, modification, and maintenance of a piece of software. 7

Metrics Available at Design Constructs/ Concepts Cyclomatic complexity (CC) N Method/ Complexity Lines of Code (LOC) N Method/ Size, complexity Comment percentage (CP) N Method/ Complexity Weighted methods per class (WMC) Y Class,Method/ Complexity Response for a class (RFC) N Class, Method/ Complexity Lack of cohesion of methods (LCOM) N Class/Cohesion Coupling between objects classes (CBO) Y Class/Coupling Depth of inheritance tree (DIT) Y Inheritance/ Complexity Number of children (NOC) Y Inheritance/ Complexity 8

Cyclomatic Complexity (CC) Also called McCabe complexity metric Evaluate the complexity of algorithms involved in a method. Give a count of the number of test cases needed to test a method comprehensively; Use a control flow graph (CFG) to describe the software module or piece of code under study: Each node corresponds to a block of sequential code. Each edge corresponds to a path created by a decision. CC is defined as the number of edges minus the number of nodes plus 2: CC= edges nodes + 2 CC= e n + 2 = 8 7 + 2 = 3 Low CC means reduced testing, and better understandability. 9

Primitive Operations of Structured Programming sequence if/then/else while for loop y=2+x; CC=2+2 = if (x>2) y=2x else y=2; CC = 4 4 + 2 = 2 while (x>2) y=2x; CC=33+2=2 for(int i=;i<5; i++) x=x+i; CC=55+2=2

Size The size of a piece of code can be measured using different metrics. (Basic) Lines of code (LOC) count all lines, including comments; Noncomment nonblank (NCNB) counts all lines except comments and blanks. Executable statements (EXEC) count the number of executable statements. Examples: if x>2 then y=x+z; /*evaluates */ if x>2 then y=x+z; High size decreases understandability, and therefore increases risk and faults. x=2z; LOC=2, NCNB= 2, EXEC= LOC=5, NCNB= 3, EXEC=2

Comment Percentage (CP) Is obtained by the total number of comments divided by the total number of lines of code less the number of blank lines. Example: Higher comment percentage means better understandability and maintainability. /*evaluates */ if x>2 then y=x+z; x=2z; /*computes */ z=x*xy; CP = 2/(82)=33% 2

Weighted Methods per Class (WMC) Is measured either by counting the number of methods associated with a class, or by summing the complexities (CC) of the methods. Example: n WMC = Σ c i, c i = CC i i= Person name: Name employeeid: Integer title: String High WMC value is a sign of high complexity, and less reusability. getcontactinformation(): ContactInformation getpersonalrecords(): Personalrecords WMC=2 3

Response For a Class (RFC) Measure the number of methods that can be invoked in response to a message to an object of the class or by some methods in the class; this includes all the methods accessible in the class hierarchy. Example: StoreDepartments manager employees Higher RFC value is a predictor of larger number of communications with other classes, so more complexity. display() credit() Clothing customer_gender size_range exchange() Appliances category delivery() service() parts_ordering() RFC (StoreDepartments) =2=+3=6 RFC(Clothing) =+2=3 RFC(Appliances)=3+2=5 4

Lack of Cohesion (LCOM) Measure the cohesion or lack of a class; evaluate the dissimilarity of methods in a class by instance variables or attributes. LCOM is measured by counting the number of pairs of methods that have no attributes in common, minus the number of methods that do. A negative difference corresponds to LCOM value of zero. Example: Low cohesion is a sign of high complexity, and shows that the class can be subdivided. High cohesion indicates simplicity and high potential for reuse. Device type:int reading:int mode: boolean compute(x:int,y:int):int update(a: int):int test(t:int) Class Device { int reading, type; boolean mode=false; } public int update (int a) {return a + reading; } public int compute(int x, int y) {return x*y*type reading;} public void test (int t) { if t == mode=true;} LCOM(Device) = 2 = 5

Coupling Between Object Classes (CBO) Measure the number of classes to which a class is coupled. Class A is coupled to class B iff A uses B s methods or instance variables. Coupling is calculated by counting the number of distinct noninheritance related class hierarchies on which a class depends. Example: JacketDepartment customer_type size_range exchange() StoreDepartments manager employees display() credit() SlacksDepartment customer_type size_range exchange() purchase() stock Supplier products Warehouse CBO(StoreDepartments) = CBO(Warehouse) = CBO(Supplier) = High coupling means increased dependency among the classes; this restricts reusability. Useful for determining reusability 6

Depth of Inheritance Tree (DIT) Measure the number of ancestor classes of a given class involved in an inheritance relation. Example: Department StoreDepartments manager employees Greater value of DIT means more methods to be inherited, so increased complexity; but at the same time that means increased reusability; so a tradeoff must be made here. Clothing customer_gender size_range exchange() display() credit() Appliances category delivery() service() parts_ordering() DIT (Appliances) =2 DIT(StoreDepartments)= DIT(Department)= 7

Number of Children (NOC) Measure the number of immediate subclasses of a class in an inheritance hierarchy. Example: StoreDepartments manager employees display() credit() High NOC means high reuse, but may also be the sign of improper abstraction or misuse of inheritance. High NOC may also be the sign of increased complexity. So a tradeoff must be made for this metric. Division NOC(Division) = NOC(StoreDepartments)= 2 NOC(Appliances)= Clothing customer_gender size_range exchange() Appliances category delivery() service() parts_ordering() 8

9 EXAMPLE: compute relevant CK metrics Message text: string WarningLtrs PeriodicMsgs Customer name:string address:string birth_date:datetime account_num:long create_customer() Purchase date:datetime tax_rate:float price() tax() Bill issue_date:datetime payment_date:datetime price() tax() customer() list_purchases() 2 4 Weighted Methods/Class Customer Message Periodic Msgs Warning Ltrs Purchase Bill Metric 2 Number of Children Customer Message Periodic Msgs Warning Ltrs Purchase Bill Metric Depth of Inheritance Tree Customer Message Periodic Msgs Warning Ltrs Purchase Bill Metric 2 Coupling Between Objects Customer Message Periodic Msgs Warning Ltrs Purchase Bill Metric

2 Lack of Cohesion in Methods 2 Coupling Between Objects Response for a Class Depth of Inheritance Tree 2 Number of Children 2 4 Weighted Methods/Class Customer Message Periodic Msgs Warning Ltrs Purchase Bill Metric

4. Metrics and Quality Metrics can be useful indicators of unhealthy code and design, pointing out areas where problems are likely to occur, by focusing on specific quality attributes. Metric Source OO Objectives Quality Attribute Construct CC Traditional M ethod Low Testability Understandability LOC Traditional M ethod Low Understandability Reusability M aintainability CP Traditional M ethod ~23% Understandability M aintainability WMC New OO Class/ Method Low Testability Reusability DIT New OO Inheritance Low (Tradeoff) Reuse Understandability M aintainability Reusability Testability NOC New OO Inheritance Low (Tradeoff) CBO New OO Coupling Low Usability M aintainability Reusability RFC New OO Class/ Method LCOM New OO Class/ Cohesion Low Low High Usability Reusability Testability Com plexity Reusability 2