ObjectOriented Metrics EEE493 2001 References:HvV 12'4 - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

ObjectOriented Metrics EEE493 2001 References:HvV 12'4

Description:

in addition to good architectural hierarchy, desire clean class inheritance hierarchies ... Software Engineering - A Practitioner's Approach 5th Edition, ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 15
Provided by: GregPh4
Category:

less

Transcript and Presenter's Notes

Title: ObjectOriented Metrics EEE493 2001 References:HvV 12'4


1
Object-Oriented Metrics EEE493 2001
ReferencesHvV 12.4
Royal Military College of Canada Electrical and
Computer Engineering
Major Ron Smith smith-r_at_rmc.ca 1-613-541-6000
ext. 6030
  • Major Greg Phillips
  • greg.phillips_at_rmc.ca
  • 1-613-541-6000 ext. 6190

2
Quality of Design ? Product Quality
  • Product maintainability and reusability are
    functions of the quality of design
  • Design quality issues include
  • complexity
  • size- versus structure-based
  • system structure
  • module dependencies (last class)
  • abstraction
  • procedural versus data versus control
  • modularity
  • cohesion versus coupling
  • information hiding
  • a modules secret(s)

(this class)
3
Use of Standard Metrics in OO
  • At the method level we could use standard
    intra-module metrics (like cyclomatic complexity)
  • provides an assessment of the design quality
    features of the code contained within methods
  • however, does not provide an assessment of the
    design quality features at the object (or class)
    level
  • At the object interaction level we could you use
    standard inter-module metrics (like tree
    impurity)
  • has limited benefit
  • fails to measure many of the desirable quality
    features unique to OO

4
Characteristics of good OO Design
  • Size
  • desire small, simple classes which can easily be
    reused and maintained
  • Hierarchy
  • in addition to good architectural hierarchy,
    desire clean class inheritance hierarchies
  • Abstraction
  • desire classes which clearly represent the
    essence of the problem domain while hiding the
    solution
  • Cohesion
  • desire both strong functional and data cohesion
  • Coupling
  • desire loose inter-class coupling

5
The CK Metrics Suite
  • 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)

CK - Chidamber and Kemerer 1994
6
Example
Constructor1( )
Constructor2( )
SetSomeAttribute( )
GetSomeAttribute( )
Sort(Array a)
Sort()
Sort()
7
Weighted methods per class (WMC)
  • A size metric
  • larger classes are more complex, take more time
    to develop / maintain and are less reusable
  • Calculate the complexity for each method
  • (e.g. using McCabes cyclomatic complexity)
  • Normalise each complexity value
  • likely that each method would have equal
    weighting
  • Sum the normalised complexity values
  • WMC ? ci wi
  • where wi 1/method_count equal weight
  • Example (Class21) WMC (11114)/5 1.6

8
Depth of inheritance tree (DIT)
  • The maximum length from a node to the root
  • 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
  • Example (Class21) DIT 2

9
Number of children (NOC)
  • The subclasses that are immediately subordinate
    to a class in the class hierarchy
  • High NOC means high reuse
  • low NOC may mean poor use of inheritance
  • But as NOC increases the parents abstraction
    may be being diluted
  • maintenance / reuse becomes more difficult
  • the number of specialized test cases increases
  • Example (Class21) NOC 1

10
Coupling between object classes (CBO)
  • A coupling metric
  • 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
  • high coupling is an indication of strong
    inter-dependencies, meaning maintainability and
    reusability will be more difficult
  • Example (Class21) CBO 2 sort( )
    dependencies

11
Response for a class (RFC)
  • Also a coupling metric (extent of coupling vs.
    number of couples)
  • 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)
  • Similarly, want this number to be low

12
Lack of cohesion in methods (LCOM)
  • This is an inverse measure of a classs cohesion
  • A 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 (class) function
  • Want to keep this low
  • Many other versions of LCOM have been defined

13
Supplemental References
  • Roger S. Pressman. Software Engineering - A
    Practitioners Approach 5th Edition, Sections
    24-3,4. McGraw-Hill, 2001. ISBN 0-07-365578-3
  • S.R. Chidamber and C.F. Kemerer. A Metrics
    Suite for Object-Oriented Design. IEEE
    Transactions on Software Engineering,
    20(6)476-493,1994.

14
Next ClassSoftware Verification Objectives
Write a Comment
User Comments (0)
About PowerShow.com