Download presentation
Presentation is loading. Please wait.
Published bySamuel Lamb Modified over 9 years ago
1
Object-Oriented Metrics Alex Evans Jonathan Jakse Cole Fleming Matt Keran Michael Ababio
2
What is OOM? Measurements ManagePredictImprove
3
LOCOM - Lack of CohesionWMC - Weighted Method CountDIT - Depth of Inheritance TreeNOC - Number of ChildrenRFC - Response for ClassCBO - Coupling Between Object Classes Chidamber-Kemerer (CK) Suite
4
Metrics of OO Design (MOOD) CF - Coupling FactorAHF - Attribute Hiding FactorMHF - Method Hiding FactorMIF - Method Inheritance FactorAIF - Attribute Inheritance FactorPF - Polymorphism Factor
5
Coupling Factor (CF) Low coupling Improves modular design Encourages reuse of components
6
Coupling Example Coupling Example Coupling Example Number of non-inheritance couplings: 7 Max Number of Couplings: (9 * 8) / 2 = 36 CF = 7/36 = 0.1944
7
Lack of Cohesion (LOCOM)
8
Correct class subdivision Decrease complexity Reduced risk of errors Increased reusability Low LOCOM
9
Cohesion Example Number of methods in class: 4 %x = 2/4 = 0.5 %y = ¼ = 0.25 %z = ¼ = 0.25 LOCOM = 1 - (0.5 + 0.25 + 0.25)/4 = 0.75
10
Hide attributes Large AHF Prevent access Attribute Hiding Factor (AHF)
11
Hide methods Large MHF Prevent Access Method Hiding Factor (MHF)
12
Encapsulation Example
13
AHF Results AttributesNumber classes not visible in%invisibilityAHF GUIfield1685%57% GUIfield2685% GUIfield3685% P1field1571% P2field1685% P3field1685% P4field1571% DS1field1...4343% DS2field1...4229%
14
MHF Results AttributesNumber classes not visible in%invisibilityMHF GUImethod()685%77% P1method1()571% P1method2()685% P1method3()571% P2method1()457% P2method2()685% P3method1()571% P4method1()571% P4method2()...4685%
15
Depth of Inheritance Tree (DIT) Max length from class node to parent Classes should be distributed evenly DIT
16
Low DIT Less complex Less reuse
17
Number of Children (NOC) Number of direct subclasses for each class NOC
18
Low NOC Reduced testing Decrease complexity Less risk of faults Less reuse
19
DIT and NOC Example
20
Some Results ClassInheritance DepthNumber of Children Entity03 Bullet12 Player10 Enemy13 Zombie20 Boss21 NeonCat30
21
Most of the classes are subclasses: Evenly Distributed DIT Results Analysis
22
Most of the classes have no children: Shallow NOC Results Analysis
23
McCabe’s Cyclomatic Complexity CC Necessary to compute WMC Evaluate complexity of algorithm Create Control Flow Graph
24
Low CC Decreased testing Increased Understanding
25
Weighted Method Count (WMC) Low WMC Increased usability Increased readability Improved Understanding
26
Edges: 8 Nodes: 7 CC: 8 - 7 + 2 = 3 CC Example
27
Weighted Method Count Example Redo classes with WMC 25 and 29 Decrease complexity
28
Response For a Class RFC Number of methods invoked by class Methods executed in response to message
29
Low RFC Reduced complexity Increased understanding Improved readability
30
RFC for Class B
31
Class B can call: FooA(), FooB(), FooB1(), FooC() (4) FooA() calls FooA1() (1) FooC() calls FooC1() (1) FooB1() and FooC1() call System.out.print () (1) RFC for Class B = 7
32
Class B Flow Chart
33
RFC Graphical Representation
34
References http://www.literateprogramming.com/ooapply.pdf http://agile.csc.ncsu.edu/SEMaterials/OOMetrics.htm http://www.arisa.se/compendium/node97.html http://www.ercim.eu/publication/Ercim_News/enw23/abreu.html http://www.cc.uah.es/drg/b/RodHarRama00.English.pdf
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.