Software Metrics 1.

Slides:



Advertisements
Similar presentations
Visual Studio Tips and Tricks Code Metrics Zain Naboulsi Sr. Developer Evangelist Microsoft Blog: blogs.msdn.com/
Advertisements

Software Metrics Software Engineering.
David Woo (dxw07u).  What is “White Box Testing”  Data Processing and Calculation Correctness Tests  Correctness Tests:  Path Coverage  Line Coverage.
1 Estimating Software Development Using Project Metrics.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
These courseware materials are to be used in conjunction with Software Engineering: A Practitioner’s Approach, 6/e and are provided with permission by.
Metrics for Process and Projects
Metrics for Process and Projects
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 Metrics.
Metrics Project and Process Metrics. Why do we measure? Assessing project status Allows us to track risks Before they go critical Adjust workflow See.
Software Metrics II Speaker: Jerry Gao Ph.D. San Jose State University URL: Sept., 2001.
March R. McFadyen1 Software Metrics Software metrics help evaluate development and testing efforts needed, understandability, maintainability.
Testing an individual module
Chapter 9: Software Metrics
Software Process and Product Metrics
Cyclomatic Complexity Dan Fleck Fall 2009 Dan Fleck Fall 2009.
University of Toronto Department of Computer Science © 2001, Steve Easterbrook CSC444 Lec22 1 Lecture 22: Software Measurement Basics of software measurement.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 27 Slide 1 Quality Management 1.
Lecture 17 Software Metrics
1 SOFTWARE MAINTENANCE. 2 Software Maintenance Software maintenance is often considered to be an unpleasant, time consuming, expensive and unrewarding.
Software Engineering Software Process and Project Metrics.
Chapter 6 : Software Metrics
SWEN 5430 Software Metrics Slide 1 Quality Management u Managing the quality of the software process and products using Software Metrics.
Metrics.
Software Measurement & Metrics
1. Software Metric- A definition 2. Types of Software metrics 3. Frame work of product metrics 4. Product metrics.
Product Metrics An overview. What are metrics? “ A quantitative measure of the degree to which a system, component, or process possesses a given attribute.”
Software Metrics Software Engineering.
Software Project Management Lecture # 3. Outline Chapter 22- “Metrics for Process & Projects”  Measurement  Measures  Metrics  Software Metrics Process.
Software Quality Metrics
Software Metrics – part 2 Mehran Rezaei. Software Metrics Objectives – Provide State-of-art measurement of software products, processes and projects Why.
Lecture 4 Software Metrics
Project Management All projects need to be “managed” –Cost (people-effort, tools, education, etc.) –schedule –deliverables and “associated” characteristics.
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.
SOFTWARE METRICS. Software Process Revisited The Software Process has a common process framework containing: u framework activities - for all software.
Computing and SE II Chapter 15: Software Process Management Er-Yu Ding Software Institute, NJU.
SOFTWARE PROCESS AND PROJECT METRICS. Topic Covered  Metrics in the process and project domains  Process, project and measurement  Process Metrics.
CSc 461/561 Information Systems Engineering Lecture 5 – Software Metrics.
Hussein Alhashimi. “If you can’t measure it, you can’t manage it” Tom DeMarco,
Advanced Software Engineering Lecture 4: Process & Project Metrics.
Object Oriented Metrics
CS223: Software Engineering Lecture 21: Unit Testing Metric.
Testing Integral part of the software development process.
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
Software Testing.
Metrics of Software Quality
Software Testing.
Software Engineering (CSI 321)
Object-Oriented Metrics
Software Project Sizing and Cost Estimation
Why Do We Measure? assess the status of an ongoing project
CS427: Software Engineering I
Design Metrics Software Engineering Fall 2003
Software Project Planning &
Design Metrics Software Engineering Fall 2003
Software Metrics “How do we measure the software?”
Chapter 13 Quality Management
Why Do We Measure? assess the status of an ongoing project
Chapter 25 Process and Project Metrics
Software metrics.
Presented by Trey Brumley and Ryan Carter
Software Metrics SAD ::: Fall 2015 Sabbir Muhammad Saleh.
Why Do We Measure? assess the status of an ongoing project
Metrics for process and Projects
Why Do We Measure? assess the status of an ongoing project
Chapter 32 Process and Project Metrics
Software Re-engineering and Reverse Engineering
Presentation transcript:

Software Metrics 1

Definitions Measure quantitative indication of extent, amount, dimension, capacity, or size of some attribute of a product or process e.g., Number of Errors Metric quantitative measure of degree to which a system, component or process possesses a given attribute. e.g., Number of errors found per person hour

Why Measure Software? Determine the quality of the current product or process Predict qualities of a product/process Improve quality of a product/process

Motivation for Metrics Estimate the cost & schedule of future projects Evaluate the productivity impacts of new tools and techniques Establish productivity trends over time Improve software quality Forecast future staffing needs Anticipate and reduce future maintenance needs

Example Metrics Defect rates Error rates Measured by: Individual Component During development Errors should be categorized by origin, type and cost

Metric Classification Products Explicit results of software development activities Deliverables, documentation, by products Processes Activities related to production of software Resources Inputs into the software development activities Hardware, knowledge, people

Product vs. Process Process Metrics Product Metrics Insights of process paradigm, software engineering tasks, work products, or milestones Lead to long term process improvement Product Metrics Accesses the state of the project Track potential risks Uncover problem areas Adjust workflow or tasks Evaluate teams ability to control quality

Types of Measures Direct Measures (internal attributes) Cost Effort LOC Speed, Memory, … Indirect Measures (external attributes) Functionality Quality Complexity Efficiency Reliability Maintainability

Size-Oriented Metrics Size of the software produced LOC – Lines of Code KLOC – 1000 Lines of Code SLOC – Statement (Source) Lines of Code (NLOC – Non-Commented Lines of Code) Function Points Typical Measures Errors/KLOC Defects/KLOC Cost/LOC Documentation Pages/KLOC

LOC Metrics Easy to use Easy to compute Language and Programmer dependent Not a very good standard “Measuring software productivity by Lines of Code is like measuring progress on an airplane by how much it weighs.” -- Bill Gates

Lines of Code? What about whitespace? Comments? Consider: Copy (char *p, *q) { while (*p) *q++ = *p++; } Copy (char *p, *q) { while (*p) *q++ = *p++; }

Lines of Code: Language Matters http://www.comp.lancs.ac.uk/computing/research/cseg/DIGITAL-LIBRARY/Renaissance/ConsultancyReport s/D33_Planning.pdf SLOC per Function Point Assembly 320 C 150 Fortran 106 Pascal 91 LISP 64 Smalltalk 21

Lines of Code… …is a valid metric when Same Language Standard Formatting Code has been reviewed

Depth of Inheritance Tree DIT is the maximum length from a node to the root of the tree (base class) Assumptions 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 Assumptions 1 and 2 tell us that having a higher number for depth is bad. However assumption 3 indicates that a higher number for depth is good for potential code reuse.

Complexity Metrics LOC – a function of complexity Cyclomatic Complexity Cohesion and Coupling

Cyclomatic Complexity A measure of logical (structural) complexity Gives an upper bound on the number of tests necessary to execute every edge of the control graph Number of independent paths (branches - if, while for) through the procedure Cyclomatic Complexity Risk Evaluation 1-10 A simple module without much risk 11-20 A more complex module with moderate risk 21-50 A complex module of high risk 51 and greater An untestable module of very high risk

Calculating Cyclomatic Complexity = (1 + IFs + Loops + Cases) where IFs is the number of IF operators in the function Loops is the number of loops in the function Cases is the number of switch branches in the function (without default)

Cyclomatic Complexity Example public override void UpdateInput() { // Get the current gamepad state. KeyboardState currentState = Keyboard.GetState(PlayerIndex.One); Keys [] keysPressed = currentState.GetPressedKeys(); foreach (Keys key in keysPressed) if (!previousKeyboardState.IsKeyDown(key)) if (commands.ContainsKey((int)key)) commands[(int)key].Execute(); // Update previous gamepad state. previousKeyboardState = currentState; }

Cyclomatic Complexity Example (cont) public override UpdateInput () foreach if ! if commands[].Execute (); done = (1 + 2{Ifs} + 1{Loops} + 0{Cases}) = 4

Visual Studio Code Metrics Calculated from Source Code Maintainability Index Cyclomatic Complexity Depth of Inheritance Class Coupling Lines of Code

Maintainability Index The maintainability index gives an indication of how easy it should be to understand and modify the code. The index is 0 <= index <= 100 with lower numbers indicating code that may be more difficult to work with (maintain) Based upon several other values Cyclomatic complexity Lines of code Halstead Volume Computational complexity of algorithms, determined by the number of operands and operators used. Fewer of each leads to better maintainability

Cyclomatic Complexity To reduce the cyclomatic complexity you should consider refactoring to extract methods If a method has a high value due to a large set of switch cases you might consider refactoring the code to use a design pattern such as the Strategy pattern

Class Coupling Indicates the amount of coupling between types in your source code. The value is the number of other types that a class uses through Properties Fields Method parameters Return values If you see the class coupling warning there is a high likelihood that your code requires refactoring

Lines of Code LOC describes the amount of source code that exists in your project or solution If the value is high for an individual member, consider refactoring LOC is not the number of lines of C# code; actually based upon the number of lines of intermediate language (IL) code after building the solution The value includes some, but not all, automatically generated code

Visual Studio Code Metrics Demonstration

?

References