180 likes | 393 Views
A Validation of Object-Oriented Design Metrics As Quality Indicators. Basili et al. IEEE TSE Vol. 22, No. 10, Oct. 96. Abstract. Suite of OOD metrics by Chidamber. Predictors of fault-prone classes? Can be used as early quality indicators? Other study: frequence of maintenance changes.
E N D
A Validation of Object-Oriented Design Metrics As Quality Indicators Basili et al. IEEE TSE Vol. 22, No. 10, Oct. 96
Abstract • Suite of OOD metrics by Chidamber. • Predictors of fault-prone classes? • Can be used as early quality indicators? • Other study: frequence of maintenance changes. • 8 medium sized information management systems
Metric • CBO: coupling between object classes: a class is coupled to another one if it uses its member functions and/or instance variables. CBO = number of classes to which a given class is coupled.
Connection to Law of Demeter • Following LoD or reducing the number of violations reduces CBO because LoD only allows good coupling.
Law of Demeter: Violation class A {public: void m(); P p(); B b; }; class B {public: C c; }; class C {public: void foo(); }; class P {public: Q q(); }; class Q {public: void bar(); }; void A::m() { this.b.c.foo(); this.p().q().bar();} CBO(A) = 4 CBO(A)= {B,C,P,Q} With LoD: CBO(A) = 2
Metric • RFC: response for a class. This is the number of methods that can potentially be executed in response to a message received by an object of that class.
Connection to Law of Demeter • Following LoD or reducing the number of violations reduces RFC because LoD allows fewer methods to be called.
Assume data member access through get method Law of Demeter: Violation class A {public: void m(); P p(); B b; }; class B {public: C c; }; class C {public: X foo(); }; class P {public: Q q(); }; class Q {public: Y bar(); }; void A::m() { this.b.c.foo(); this.p().q().bar();} RFC(A) = 6 RFC(A)= {b,c,p,q,foo,bar} With LoD: RFC(A) = 4 RFC(A)= {b,p,foo2,bar2} But …
Assume data member access through get method Law of Demeter: Violation With LoD: RFC(A) = 4 RFC(B) = 2 RFC(P) = 2 8 class A {public: void m(); P p(); B b; }; class B {public: C c; void foo2() {c.foo();}; class C {public: X foo(); }; class P {public: Q q(); void bar2(){q().bar(); }; class Q {public: Y bar(); }; void A::m() { this.b.foo2(); this.p().bar2();} Without LoD: 6 + 0 + 0 = 6 LoD spreads RFC but it might increase it!
Assume data member access through get method Law of Demeter: Violation Illustrate better separation RFC(A) = 4 RFC(B) = 2 RFC(P) = 2 8 class A {public: void m(); P p(); B b; }; class B {public: C c; }; class C {public: X foo(); }; class P {public: Q q(); }; class Q {public: Y bar(); }; void A::m() { X x=M.cg.fetch(this,”from A to X”); Y y=M.cg.fetch(this,”from A to Y”);} RFC(A)={fetch} With LoD: RFC(A) = 1 CBO(A)= {DJ.ClassGraph}
Class Diagram m from A to X c foo() b B C X A q() bar() p() from A to Y Y P Q
Hypotheses • H-CBO: Highly coupled classes are more fault-prone than weakly coupled classes because they depend more heavily on methods and objects defined elsewhere. • H-RFC: Classes with larger response sets implement more complex functionalities and are, therefore, more fault-prone.
RFC (on projects) Y • X axis: values of metric. • Y axis: number of classes. Probability of fault detection increases X
CBO (on projects) Y • X axis: values of metric. • Y axis: number of classes. Probability of fault detection increases X
Results • RFC is very significant. The H-RFC hypothesis is supported. • CBO is significant, particularly for UI classes.
Analysis Methodology • Response variable: binary: was a fault detected in a class during testing? • Used logistic regression, a standard technique used in experimental sciences. • Alternatives would be: classification trees, optimized set reduction, or neural networks.
Study Participants • Four months • Students in a class on OO software analysis and design • Control differences in skills: randomly grouped into eight teams. • Used blocking: eight most experienced students randomly assigned to a different group.
Development Process for Video Store Application • Sequential software engineering life-cycle model based on waterfall model: analysis, design, implementation, testing and repair. • Requirement and design document were checked. • OMT (Rumbaugh) was used • C++ with MotifApp, GNU library, database library.