Note 6. Software Metrics

Size: px
Start display at page:

Download "Note 6. Software Metrics"

Transcription

1 Computer Science and Software Engineering University of Wisconsin - Platteville Note 6. Software Metrics Yan Shi Lecture Notes for SE 3730 / CS 5730 Part of the slides are adopted from Pearson s slides

2 Outline What is a software metric? Software size metrics KLOC Function Points Software quality metrics process metrics product metrics Software complexity metrics Halstead s metrics

3 What is a Metric? A metric is a measurable indication of some quantitative aspect of a system with the following characteristics: Measurable Independent of human influence Accountable: save the raw data Precise E.g., Number of errors found per person hours. A metric can be a result or a predictor. determine the quality predict and improve quality

4 Software Size Metrics KLOC CoCoMo (Constructive Cost Model): Real-time embedded system: System programs: Commercial applications: KLOC has dependence on the programming language or development tool LOC/man-month LOC/man-month LOC/man-month Function Point: measure the project size by functionality specified for that system. result or predictor?

5 COCOMO Overview COCOMO consists of a hierarchy of three increasingly detailed and accurate forms. Basic COCOMO Model Intermediate COCOMO Model Detailed COCOMO Model All of these models can be applied to a variety of projects, whose characteristics determine the value of constant to be used in subsequent calculations. Organic: well understood problem; small team with past experience Semi-detached: somewhere in between Embedded: highest level of complexity; large team with experience and creativity.

6 Basic COCOMO Model Effort Applied (E) = a b (KLOC) b b [ man-month ] Development Time (D) = c b (Effort Applied) d b [months] People required (P) = Effort Applied / Development Time [count] Software Project a b b b c b d b organic Semi-detached embedded

7 Function Point Method Step1: Compute crude function points (CFP) Step2: Compute the relative complexity adjustment factor (RCAF) for the project. RCAF varies between 0 and 70. Step3: Compute the number of function points (FP): FP = CFP ( RCAF)

8 Function Point Method Step1 Step1: Compute crude function points (CFP) identify functional components evaluate each component as simple, average or complex apply weighting factors to the components CFP is the summed weighted values

9 Function Point Method Step1 Step1: Compute crude function points (CFP) 2.evaluate each component 1.identify functional components 4.CFP is the summed weighted values 3.apply weighting factors

10 FP Example: Attend Master System Data Flow Diagram Pearson Education Limited 2004 & cah, UoN 2008

11 FP Example: Attend Master System Software system components Count Complexity level Simple average complex Weight Factor A B C= AxB Points Count Weight Factor D E F= DxE Points Count Weight Factor Points G H I= GxH User inputs Total CFP User outputs User online queries Logical files External interfaces Total CFP 81 Pearson Education Limited 2004 & cah, UoN 2008

12 Function Point Method Step2 Step2: Compute the relative complexity adjustment factor (RCAF) for the project. assign grades (0-5) to the 14 subjects that substantially affect the development effort: RCAS = sum of all grades

13 Function Point Method Step2 Pearson Education Limited 2004 & cah, UoN 2008

14 FP Example: Attend Master System No Subject Grade 1 Requirement for reliable backup and recovery Requirement for data communication Extent of distributed processing Performance requirements Expected operational environment Extent of online data entries Extent of multi-screen or multi-operation online data input Extent of online updating of master files Extent of complex inputs, outputs, online queries and files Extent of complex data processing Extent that currently developed code can be designed for reuse Extent of conversion and installation included in the design Extent of multiple installations in an organization and variety of customer organizations Extent of change and focus on ease of use Total = RCAF 41 Pearson Education Limited 2004 & cah, UoN 2008

15 FP Example: Attend Master System FP = CFP x ( x RCAF) FP = 81 x ( x 41) = Pearson Education Limited 2004 & cah, UoN 2008

16 FP: Benefits and Drawbacks FP can be used as a predictor to estimate the project size/ resources needed during project planning! as long as we have requirement specification However, it is very subjective depend on the estimators expert knowledge cannot be counted automatically Not universally applicable best for data processing systems Detailed requirement specification may not be available during planning phase! Estimating LOC based on FP and language: QSM Function Point Programming Language Table

17 Software Quality Metrics Quality Quality metrics Development Process metrics Product metrics Maintainace Timetable Effectiveness Productivity

18 Software Process Quality Metrics Error Density and Severity Metrics. need: Errors counted: NCE: number of code errors WCE: weighted number of code errors NDE: number of development errors (design+code) WDE: weighted number of development errors How to decide weight? Critical: blocking other tests and alpha release, 9 Severe: blocking other tests and beta release, 6-8 Moderate: testing workaround possible, but blocking final release ~3 Very minor: fix before the Sun Burns Out 1 Product size: KLOC or FP

19 Error Density metrics Code Name Calculation formula CED Code Error Density CED = NCE / KLOC DED Development Error Density DED = NDE / KLOC WCED Weighted Code Error Density WCDE = WCE / KLOC WDED Weighted Development Error Density WDED = WDE / KLOC WCEF WDEF Weighted Code Errors per Function Point Weighted Development Errors per Function Point WCEF = WCE / NFP WDEF = WDE / NFP CED > 2 and WCED > 4 : unacceptable software quality

20 Error Severity Metrics Code Name Calculation formula ASCE ASDE Average Severity of Code Errors Average Severity of Development Errors WCE ASCE = NCE WDE ASDE = NDE

21 Software Process Timetable Metrics Code Name Calculation formula TTO Time Table Observance MSOT TTO = ADMC Average Delay of Milestone Completion MS TCDAM ADMC = MS MSOT = Milestones completed on time. MS = Total number of milestones. TCDAM = Total Completion Delays (days, weeks, etc.) for all milestones.

22 Error Removal Effectiveness Metrics Code Name Calculation formula DERE Development Errors Removal NDE DERE = Effectiveness NDE + NYF DWERE Development Weighted Errors Removal Effectiveness WDE DWERE = WDE+WYF NYF = number of software failures detected during a year of maintenance service. WYF = weighted number of software failures detected during a year of maintenance service.

23 Software Process Productivity Metrics Code Name Calculation formula DevP FDevP CRe DocRe Development Productivity Function point Development Productivity Code Reuse Documentation Reuse DevH DevP = KLOC DevH FDevP = NFP ReKLOC Cre = KLOC ReDoc DocRe = NDoc DevH = Total working hours invested in the development of the software system. ReKLOC = Number of thousands of reused lines of code. ReDoc = Number of reused pages of documentation. NDoc = Number of pages of documentation.

24 Software Product Metrics HD(help desk) quality metrics: HD calls density metrics - measured by the number of calls. HD calls severity metrics - the severity of the HD issues raised. HD success metrics the level of success in responding to HD calls. HD productivity metrics. HD effectiveness metrics. Corrective maintenance quality metrics. Software system failures density metrics Software system failures severity metrics Failures of maintenance services metrics Software system availability metrics Corrective maintenance productivity and effectiveness metrics.

25 Define New Software Quality Metrics

26 Complexity Metrics Halstead s metrics Complexity of a piece of code depends on: n 1 : number of unique operators n 2 : number of unique operands N 1 : total number of occurrences of operators N 2 : total number of occurrences of operands McCabe s metrics graph complexity based on control flow graphs

27 Halstead s Metrics[1977] Program length: N = N 1 + N 2 Program vocabulary: n = n 1 + n 2 Estimated length: Nˆ = n 1 log 2 n 1 + n 2 log 2 n 2 Close estimate of length for well structured programs Purity ratio: PR = /N code optimization: the higher the ratio above 1.0, the more optimized the code. Program volume: V = N log 2 n Number of bits to provide a unique designator for each of the n items in the program vocabulary. Difficulty: Nˆ Program effort: E=D*V This is a good measure of program understandability

28 Exercise: Halstead s Metrics Distinct operators: if ( ) { } > < = * ; Distinct operands: k 5 2 x if (k < 5) { if (k > 2) x = x*k; } n 1 : number of unique operators 10 n 2 : number of unique operands 4 N 1 : total number of occurrences of operators N 2 : total number of occurrences of operands 13 7 Calculate Halstead s metrics!

29 Exercise: Halstead s Metrics Program length: N = N 1 + N 2 = 20 Program vocabulary: n = n 1 + n 2 = 14 Estimated length: Nˆ = n 1 log 2 n 1 + n 2 log 2 n 2 = 41.2 Purity ratio: PR = /N = 2.1 Program volume: V = N log 2 n = 76.1 Difficulty: = 8.75 Program effort: E = D*V = Nˆ

30 Object Oriented Metrics A way to characterize the objectorientedness of a design (Shyam Chidamber and Chris Kemerer, 1994) Weighted methods per class depth of inheritance tree number of children coupling between object classes response for a class lack of cohesion in methods

31 Defect Cost Analysis Defect injection point: In what stage of the development cycle was the defect put into the system? Defect detection point: In what stage of the development cycle was the defect discovered? The latency between injection and detection point of a defect: the longer, the more expensive to fix. This analysis help evolve a process to prevent defects and reduce the latency.

32 Summary What is a software metric? Software size metrics KLOC Function Points Software quality metrics process metrics: development quality, timetable, effectiveness, productivity product metrics: maintainace Software complexity metrics Halstead s metrics: n1, n2, N1, N2 Defect Cost Analysis