Title: OO Metrics EEE493 2000
1OO Metrics EEE493 2000
Royal Military College of Canada Electrical and
Computer Engineering
- Major Greg Phillips
- greg.phillips_at_rmc.ca
- 1-613-541-6000 ext. 6190
Dr. Scott Knight knight-s_at_rmc.ca 1-613-541-6000
ext. 6190
2Refs
- Pressman, R.S., Software Engineering a
Practitioners Approach 5th Ed., McGraw-Hill,
2001, Section 24.3 and 24.4
3Teaching Points
- Metrics for size/complexity
- Metrics for coupling
- Metrics for cohesion
- The CK metrics suite
4Review
- How can we calculate McCabe numbers for a module?
- How were McCabe numbers used in the Aurora
mission computer software case study?
5The Intent of Object-oriented Metrics
- To better understand the quality of the product
- to assess the effectiveness of the process
- to improve the quality of the work performed at a
project level - i.e. no different than those derived for
conventional software
6Nine Distinct and Measurable Characteristics of
an OO Design
- Size
- May be determined in 4 views population, volume,
length, and functionality - Complexity
- McCabe style complexity
- How classes of an OO design are interrelated to
one another - Coupling
- The physical connection between elements of an OO
design
7Nine Distinct and Measurable Characteristics of
an OO Design
- Sufficiency
- The degree to which an abstraction possesses the
features required of it - e.g. a class is sufficient if it fully reflects
all properties of the application domain it is
modelling - Completeness
- Similar to Sufficiency
- But, considers the what properties are required
to fully represent the problem domain object - Cohesion
- The extent to which the methods of a class are
all working together to achieve a single
well-defined purpose
8Nine Distinct and Measurable Characteristics of
an OO Design
- Primitiveness
- The degree to which a class/method is atomic
- i.e. a method cannot be constructed out of a
sequence of other methods in the class - Similarity
- The degree to which two or more classes are
similar in terms of their structure, function,
behaviour, or purpose - Volatility
- The likelihood that change will occur
- changes in other parts of the application may
result in mandatory adaptation of the design
component in question
9The CK Metrics Suite
- Proposed by Chidamber and Kemerer
- One of the most widely referenced sets of OO
metrics - 6 metrics
- Weighted methods per class (WMC)
- Depth of inheritance tree (DIT)
- Number of children (NOC)
- Coupling between object classes (CBO)
- Response for a class (RFC)
- Lack of cohesion in methods (LCOM)
10Weighted methods per class (WMC)
- A size/complexity measure
- Calculate the complexity for each method (e.g.
using McCabe numbers) - Normalise the each complexity value
- Sum the normalised complexity values
- We want to keep this number low
- But how many methods in a class?
11Depth of inheritance tree (DIT)
- The maximum length from a node to the root of the
tree - As DIT grows the lower-level classes inherit many
methods (making them hard to understand)(greater
design complexity) - But large DIT values imply that we have good
reuse - DIT values must be balanced
12Number of children (NOC)
- The subclasses that are immediately subordinate
to a class in the class hierarchy - High NOC means high reuse
- But as NOC increases the parents abstraction
may be being diluted the number of specialized
test cases increases
13Example
- What is DIT?
- What is NOC?
14Coupling between object classes (CBO)
- A count of
- The number of other classes which access a method
or variable in this class, or - contain a method or variable accessed by this
class - Want to keep this low
15Response for a class (RFC)
- Measures the number of methods in a class that
can be executed in response to a message received
by an object of that class (includes methods in
base classes) - Also a coupling metric (extent of coupling vs.
number of couples)
16Lack of cohesion in methods (LCOM)
- This is an inverse measure of a classs cohesion
- The count of methods that do not have a common
attribute with at least one other method - High values indicate methods and attributes are
not related to a single function - Want to keep this low
- Many other version of LCOM have been defined
17Next ClassProcess Improvement