SOFTWARE METRICS
Software Process Revisited
The Software Process has a common process framework containing:
framework activities - for all software projects work tasks project milestones software work products and deliverables quality assurance points
umbrella activities - occur throughout the process software quality assurance software configuration management software metrics or measurement
Measurement
• Measurement is fundamental to engineering
• ‘When you can measure what you are speaking about and express it in numbers, you know something about it; but when you cannot measure, when you cannot express it in numbers, your knowledge is of a meager and unsatisfactory kind’.
(Lord Kelvin)
Software Metrics
• Software Metrics refers to measurements relating to computer software.
• Software Metrics can assist in:– Improving the software process by:
• Assessing productivity and estimating • Controlling the project and its quality
– Assessing the quality of a software product
Scope of Software Metrics
Software Metrics has two main fields of application:– Measure/assessment of a software product or
process (eg a baseline – as it is now)– Prediction of critical features involved in a
software project (ie a future estimate)
Software Product/Process Measurement
An integral part of the Project Plan Aims to provide data which can be used to
better control the production of software
“You cannot control what you cannot measure”
Tom de Marco (1982)
The Need for Software Metrics
Software Production suffers from– Excessive Costs (especially Maintenance)
– Low Productivity & Poor Quality
– Lack of Standards, Professionalism
because we fail to set measurable targets:– Measure the ‘real’ costs in projects
– Quantify the quality
– Properly evaluate new tools and techniques
The Need for Software Metrics....Managers need to:
– Measure System Costs to determine a realistic price– Measure Productivity of Staff, to set company-wide
productivity goals– Measure ‘whole of system’ costs to better estimate
complexity, schedule, resources and budgets– Measure the ‘added value’ of the project to the
organisation
The Need for Software Metrics.... Software Developers need to:
– Monitor the quality of evolving systems by making regular process measurements
– Specify quality and performance requirements in measurable terms
– Identify potentially complex components– Measure the reliability of the product– Measure the quality of software, to determine
methods, baselines, targets etc
Main Issues
Software Metrics are used to help improve these aspects of a system:
Visibility QualityProductivityPlanning and control
Cost Estimation Process
Cost Estimation Process
• To estimate the Cost of a system – it is important to know the Size of the system
– Typical Size measures are:
• LOC – Lines of Code• FP – Function Points
Software Size and Complexity Estimating/Measuring Software Size
Measures must be: Useful for planning Precise Automatically countable
Estimate must be: Available early in the life-cycle
Estimation of Effort requires knowledge of the Complexity of a system
Useful technique is COCOMO
Software Size ...
Usefulness of Measures for Planning ...
– Development time is a function of program size• the time it takes to develop a program depends upon
the size (and the complexity) of the program
– On a large project there may be many kinds of products– Product size measures should correlate to the effort/
hours you need to develop them– Source Lines of Code (SLOC) is a common size
measure
LOC ...
Lines of Code (LOC)or SLOC – Source Lines of Code
Defining LOC» use complete definitions
» you or your organisation should develop a Standard» (eg C++ SLOC Counting Standard – refer Attachment)
LOC ...
What factors influence a definition of LOC?– Language
– Count Type: Logical or physical
– Compiler Directives
– Comments» Not general practice to include comments but there should be a
coding standard to cover this
» Comments are part of the Eiffel standard so should be included in the LOC
– Blank lines - not usually counted
LOC ...
What factors influence a definition of LOC?– Statement Type
» Executable - but what about class_monitor.my_menu.activate thisPage.PrintL(Mylist.GetString(ThisData,1)) Logical constructs if..then..else Reused code
» Declarations class MONITOR I,J : INTEGER Preconditions, postconditions begin..end
LOC ...
Physical LOC Counters– Simplest type of counter– Ignore blank lines– Comment lines?– It is useful to keep totals for each program unit
» What units should we keep totals for? (Eiffel class?)» How would we determine the start / end of a unit?
Exercise: Produce a Physical LOC count standard for Eiffel
LOC ...
Logical LOC CountersWorks the same as a Physical LOC counter, but Line-counter stepping is more complex
» Establish a logical line-count standard» No one counting method superior to another» BE CONSISTENT!
You could set coding standards to write one Logical LOC per line then you would combine two methods in one.
LOC ...
Using the LOC Count Measurement Types
– An Eiffel LOC count is different from» a C++ LOC count
» an Assembler LOC count
– You should not mix LOC counts for » test code, support code, product code
LOC ...
Using the LOC Count ... Meaning of LOC
– If 2 programmers code the same program» Programmer A produced 1200 LOC in 117 hours» Programmer B produced 793 LOC in 61 hours
– therefore Programmer B » took much less time, » produced 30% more LOC per hour
What does LOC tell us?
LOC ...
LOC and Project Evaluation– Estimated time to develop
• Historical information from the same type of project will give an estimated LOC per working hour
– Total defects found per LOC or defects/KLOC• A standard measurement
– Maintenance• Small code changes to large programs are a significant
quality concern
• Small code changes are almost 40 times as error prone as new development
LOC ...
• Counting Issues– For software reuse:
Do we count reused code?– Reused code affects:
• Definition of productivity – LOC per day• Quality measurement – defects per KLOC
– If reuse should be rewarded, it should be counted!!!– For maintenance:
Do we count modified code and deleted code?
LOC ...
LOC Counting Methods– You can get almost any numbers you want ...
Option LOC Productivity
(LOC/hour)Added 500 8.33Added + Modified 600 10.00Added + Modified + Deleted 800 13.33Added + Modified + Reused 1200 20.00Added + Modified + Deleted + Reused 1400 23.33Total Finished Product 900 15.00
LOC ...
Problems with LOC for Estimation
Hard to judge at project start All software projects unique Historical data may assist Need to determine the difference between new
project and last
Need a proxy, a stand-in for LOC
OO Metrics
Proxies1. Classes as Proxies
• Satisfy criteria:» Related to development effort
» Automatically countable
» easily visualized at project start
2. Routines/Features as Proxies» Gives finer-grained measure
» You could weight a class by the number of routines it contains
OO Metrics ...
Categories of ClassesThree broad categories of classes in an application:
» Model application classes
» View menus, windows etc.
» Controller Commands
Do the classes in each category exhibit different size characteristics?
Is the code in each easier or harder to write?
OO Metrics ...
For your assignment, calculate: For each class category:
Number of classesFor each class:
For each routine implemented hereLOC count for each routine
Average length / class in the category Note the difference
– In average length of class / category
Summary
‘You cannot control
what you cannot measure’
Tom de Marco