Metrics of Software Quality

Slides:



Advertisements
Similar presentations
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
Advertisements

1 Software Design Introduction  The chapter will address the following questions:  How do you factor a program into manageable program modules that can.
What is Software Design?  Introduction  Software design consists of two components, modular design and packaging.  Modular design is the decomposition.
Copyright Irwin/McGraw-Hill Software Design Prepared by Kevin C. Dittman for Systems Analysis & Design Methods 4ed by J. L. Whitten & L. D. Bentley.
IMSE Week 18 White Box or Structural Testing Reading:Sommerville (4th edition) ch 22 orPressman (4th edition) ch 16.
SE-565 Software System Requirements More UML Diagrams.
Cyclomatic Complexity Dan Fleck Fall 2009 Dan Fleck Fall 2009.
Lecture 17 Software Metrics
INTRODUCTION TO PROGRAMMING STRUCTURE Chapter 4 1.
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
Chapter 6 : Software Metrics
Agenda Introduction Overview of White-box testing Basis path testing
SE: CHAPTER 7 Writing The Program
Software Metrics (Part II). Product Metrics  Product metrics are generally concerned with the structure of the source code (example LOC).  Product metrics.
Concepts of Software Quality Yonglei Tao 1. Software Quality Attributes  Reliability  correctness, completeness, consistency, robustness  Testability.
Cohesion and Coupling CS 4311
4/1/05F-1 © 2001 T. Horton CS 494 Object-Oriented Analysis & Design Packages and Components in Java and UML.
Programming Logic and Design Using Methods. 2 Objectives Review how to use a simple method with local variables and constants Create a method that requires.
Software Engineering Principles. SE Principles Principles are statements describing desirable properties of the product and process.
An Automatic Software Quality Measurement System.
CSc 461/561 Information Systems Engineering Lecture 5 – Software Metrics.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
CPSC 871 John D. McGregor Module 8 Session 1 Testing.
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
Agent program is the one part(class)of Othello program. How many test cases do you have to test? Reversi [Othello]
Systems Design.  Application Design  User Interface Design  Database Design.
Cyclomatic complexity (or conditional complexity) is a software metric (measurement). Its gives the number of indepented paths through strongly connected.
Cyclomatic Complexity Philippe CHARMAN Last update:
Chapter 10 Software quality. This chapter discusses n Some important properties we want our system to have, specifically correctness and maintainability.
Programming Logic and Design Fifth Edition, Comprehensive Chapter 7 Using Methods.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Software Test Metrics When you can measure what you are speaking about and express it in numbers, you know something about it; but when you cannot measure,
Static Software Metrics Tool
Coupling and Cohesion Rajni Bhalla.
Integration Testing.
Software Metrics 1.
Software Testing.
Software Testing.
Cyclomatic complexity
Coupling and Cohesion 1.
Software metric By Deepika Chaudhary.
Software Engineering (CSI 321)
Managing the System PPT SOURCE : Shari L. Pfleeger Joann M. Atlee.
System Design.
Software Design and Architecture
TK2023 Object-Oriented Software Engineering
Structural testing, Path Testing
Celia Chen1, Lin Shi2, Kamonphop Srisopha1
Lecture 17 Software Metrics
Software testing strategies 2
Software Testing (Lecture 11-a)
Improving the Design “Can the design be better?”
What’s changed in the Shibboleth 1.2 Origin
Software Engineering Lecture #8.
Software Metrics “How do we measure the software?”
Programming Logic and Design Fourth Edition, Comprehensive
Analysis models and design models
Software Design Lecture : 9.
Software Design Lecture : 8
An Introduction to Software Architecture
Presented by Trey Brumley and Ryan Carter
Software Metrics SAD ::: Fall 2015 Sabbir Muhammad Saleh.
Software Metrics using EiffelStudio
Applying Use Cases (Chapters 25,26)
Applying Use Cases (Chapters 25,26)
CS 2704 Object Oriented Software Design and Construction
TECHNICAL PAPER PRESENTATION By: Srihitha Yerabaka
Cohesion and Coupling.
Paul Ammann & Jeff Offutt
Unit III – Chapter 3 Path Testing.
Presentation transcript:

Metrics of Software Quality 5/11/2018 Prepared by Charlie Meyer, April 2008

What are software metrics? Quantitative measurements distilled from data Distilled by measuring software development processes and actual source code Highlight areas that need work in specific nodes of code as well as generalizations about your code overall “You can’t control what you can’t measure” –Tom DeMarco 5/11/2018 Prepared by Charlie Meyer, April 2008

Limitations of metrics Software metrics are intended to help programmers control and monitor software production, but… It’s difficult to determine “how much” software there is in a given program Can give a skewed impression of software, especially when calculated early in the software development process Can be difficult or complex to calculate, especially as the volume of code grows 5/11/2018 Prepared by Charlie Meyer, April 2008

Examples of software metrics Lines of code Number of classes & interfaces Code to comment ratio Cyclomatic complexity Code coverage Bugs to lines of code ratio Cohesion Coupling Failed tests per build Version control commits per day Lines of code per commit … 5/11/2018 Prepared by Charlie Meyer, April 2008

Terminology Node Program Flow graph A block of source code, usually either a single line, a function/method, class, or package. A node can have multiple children, but only one direct parent Program A graph of all of the nodes that comprise the source code Flow graph A directed graph of all of the single line nodes connected with vertices where the possible flow of execution might proceed 5/11/2018 Prepared by Charlie Meyer, April 2008

Lines of code A key size attribute of software Can be a good measure of software volatility, especially when tracked over the entire development process Can be used as the basis for other metrics, such as the bugs:code and tests:code ratios 5/11/2018 Prepared by Charlie Meyer, April 2008

Code to comment ratio We’ve already seen how important commenting is to developing quality code This metric puts a numerical value on the amount of inline documentation in a piece of software Gives developers warning on when code needs to be documented 5/11/2018 Prepared by Charlie Meyer, April 2008

Cyclomatic Complexity Directly measures the number of linearly independent paths through source code CC = E - N + p where E = the number of edges of the program’s flow graph N = the number of nodes of the graph p = the number of connected components of the graph If code contains no decisions, then CC=1, if a piece of code contains a binary if statement, CC=2, etc… 5/11/2018 Prepared by Charlie Meyer, April 2008

Cyclomatic complexity cont. Upper bound on the number of unique test cases required to have complete coverage of a given branch Commonly used thresholds: Cyclomatic Complexity Risk Evaluation 1-10 A simple program without much risk 11-20 More complex, moderate risk 21-50 Complex & high risk >50 Practically untestable, very high risk 5/11/2018 Prepared by Charlie Meyer, April 2008

More cyclomatic complexity….. Lower CC contributes to a program’s understandability and indicates that it is more easily modifiable Generally, the greater CC becomes, the more complex and unmaintainable the code becomes Greater cyclomatic complexity indicates a greater learning curve for new developers 5/11/2018 Prepared by Charlie Meyer, April 2008

Code coverage A metric that describes to extent to which the source code of a program has been tested Different degrees of code coverage: Function coverage - Has each function in the program been executed? Statement coverage - Has each line of the source code been executed? Condition coverage - Has each evaluation point (such as a true/false decision) been executed? Path coverage - Has every possible route through a given part of the code been executed? Entry/exit coverage - Has every possible call and return of the function been executed Some of the above are connected together 5/11/2018 Prepared by Charlie Meyer, April 2008

Code coverage & unit tests Indicator of how well your tests actually test your code Lets you know if you have enough tests in place Allows you to maintain the quality of your test suite over the lifetime of the project 5/11/2018 Prepared by Charlie Meyer, April 2008

How code coverage works (in java) 1. compile the source code 2. instrument the compiled class files, excluding the compiled test cases. This adds the necessary information to allow for… 3. Collect runtime data 4. merge the runtime data into a auditable report When the tests are executed, the extra info added in when the files were instrumented will write out exact coverage data to disk 5/11/2018 Prepared by Charlie Meyer, April 2008

Cohesion Cohesion is a measure of how strongly- related the various responsibilities of a software module are A node is usually deemed to have “high cohesion” or “low cohesion” High Cohesion can indicate many things about code, including the extent of reuse of code and readability 5/11/2018 Prepared by Charlie Meyer, April 2008

Disadvantages of low cohesion Increased difficulty in understanding nodes of source code Increased difficulty in maintaining source code - changes will affect multiple nodes, changes in one node will require changes in many other nodes Increased difficulty in reusing a node of source code, since most other nodes will not need the functionality that a node with low cohesion provides 5/11/2018 Prepared by Charlie Meyer, April 2008

Coupling Coupling is the extent to which a node relies on the other nodes in the source code Nodes can be called either “loosely/weakly coupled” or “strongly/tightly coupled” Loose coupling indicates high cohesion! Loose coupling refers to a relationship between nodes such that one node interacts with the other nodes via a stable interface and does not need be concerned with the internal implementation of the other nodes 5/11/2018 Prepared by Charlie Meyer, April 2008

Types of coupling Content coupling (tightest) Common coupling is when one node modifies or relies on the internal workings of another node Common coupling is when nodes share the same global data External coupling Is when nodes rely on an external data format Data coupling Is when nodes share data through parameters Message coupling (loosest) Is when modules are not dependent on each other, they use a public interface to communicate 5/11/2018 Prepared by Charlie Meyer, April 2008

Methods for decreasing coupling and increasing cohesion Transmit messages between nodes in a flexible format (such as XML) Use public interfaces to communicate messages between nodes where a file format is not required Separate code into nodes that perform logical chunks of work (example: MVC pattern) Write code such that the implementation of a given node of code is independent from how it is used by other nodes 5/11/2018 Prepared by Charlie Meyer, April 2008

Free tools for auditing software http://cyvis.sourceforge.net/ (java) http://cccc.sf.net/ (c, c++) http://emma.sourceforge.net http://pmd.sourceforge.net Many other open source alternatives exist, google is your friend There are also commercial alternatives targeted for larger projects 5/11/2018 Prepared by Charlie Meyer, April 2008

Works cited http://en.wikipedia.org/wiki/Software_metric http://www.sei.cmu.edu/str/descriptions/cyclom atic_body.html http://en.wikipedia.org/wiki/Code_coverage http://www.cenqua.com/clover/doc/coverage/in tro.html http://c2.com/cgi/wiki?CouplingAndCohesion http://en.wikipedia.org/wiki/Cohesion_%28comp uter_science%29 http://en.wikipedia.org/wiki/Coupling_%28comp uter_science%29 5/11/2018 Prepared by Charlie Meyer, April 2008