Professional Documents
Culture Documents
Object Oriented Metrics
Object Oriented Metrics
Does a class reflect the necessary properties of the problem domain? Completenes
s Does a class reflect all the properties of the problem domain? (for reuse) Coh
esion Do the attributes and operations in a class achieve a single, well-defined
purpose in the problem domain? Primitiveness (Simplicity) Degree to which class
operations cant be composed from other operations Similarity Comparison of struc
ture, function, behavior of two or more classes Volatility The likelihood that a
change will occur in the design or implementation of a class
Chidamber and Kemerer metrics suite for OO Design is the deepest research in OO
metrics investigation. s They have defined six metrics for the OO design. In th
is section well have a complete description of their metrics: Metric 1: Weighted
Methods per Class (WMC) Definition: Consider a Class C1, with methods M1... Mn t
hat are defined in the class. Let c1... cn be the complexity of the methods. The
n:
n
2. Chidamber & Kemerer s Metrics Suite
WMC =
i =1
ci
If all method complexities are considered to be unity, then WMC = n, the number
of methods. Theoretical basis: WMC relates directly to Bunge 1 definition of com
plexity of a thing, since methods are s properties of object classes and complex
ity is determined by the cardinality of its set of properties. The number of met
hods is, therefore, a measure of class definition as well as being attributes of
a class, since attributes correspond to properties. Viewpoints The number of me
thods and the complexity of methods involved is a predictor of how much time and
effort is required to develop and maintain the class. The larger the number of
methods in a class the greater the potential impact on children, since children
will inherit all the methods defined in the class. Classes with large numbers of
methods are likely to be more application specific, limiting the possibility of
reuse. Metric 2: Depth of Inheritance Tree (DIT) Definition: Depth of inheritan
ce of the class is the DIT metric for the class. In cases involving multiple inh
eritance, the DIT will be the maximum length from the node to the root of the tr
ee. Theoretical basis: DIT relates to Bunge notion of the scope of properties.
DIT is a measure of how many s ancestor classes can potentially affect this clas
s. Viewpoints: The deeper a class is in the hierarchy, the greater the number of
methods it is likely to inherit, making it more complex to predict its behavior
. Deeper trees constitute greater design complexity, since more methods and clas
ses are involved. The deeper a particular class is in the hierarchy, the greater
the potential reuse of inherited methods.
The ontological principles proposed by Bunge in his Treatise on Basic Philosophy f
orm the basis of the concept of objects. While Bunge did not provide specific on
tological definitions for object oriented concepts, several recent researchers h
ave employed his generalized concepts to the object oriented domain.
1
The LCOM i a count of the number of method pair whoe imilarity i 0 (i.e. ()
i a null et) minu the count of method pair whoe imilarity i not zero. The
larger the number of imilar method, the more coheive the cla, which i con
itent with traditional notion of coheion that meaure the interrelatedne b
etween portion of a program. If none of the method of a cla diplay any int
ance behavior, i.e. do not ue any intance variable, they have no imilarity a
nd the LCOM value for the cla will be zero. The LCOM value provide a meaure
of the relative diparate nature of method in the cla. A maller number of di
joint pair (element of et P) implie greater imilarity of method. LCOM i
intimately tied to the intance variable and method of a cla, and therefore
i a meaure of the attribute of an object cla. Viewpoint: Coheivene of m
ethod within a cla i deirable, ince it promote encapulation. Lack of coh
eion implie clae hould probably be plit into two or more ub-clae. Any
meaure of diparatene of method help identify flaw in the deign of cla
e. Low coheion increae complexity, thereby increaing the likelihood of erro
r during the development proce. The MOOD metric et refer to a baic truct
ural mechanim of the OO paradigm a encapulation ( MHF and AHF ), inheritance
( MIF and AIF ), polymorphim ( PF ) , meage-paing ( CF ) and are expreed
a quotient. The et include the following metric: Method Hiding Factor ( MH
F ) MHF i defined a the ratio of the um of the inviibilitie of all method
defined in all clae to the total number of method defined in the ytem unde
r conideration. The inviibility of a method i the percentage of the total cla
e from which thi method i not viible. note : inherited method not conide
red. Attribute Hiding Factor ( AHF ) AHF i defined a the ratio of the um of t
he inviibilitie of all attribute defined in all clae to the total number o
f attribute defined in the ytem under conideration. Method Inheritance Facto
r ( MIF ) MIF i defined a the ratio of the um of the inherited method in all
clae of the ytem under conideration to the total number of available meth
od ( locally defined plu inherited) for all clae. Attribute Inheritance Fac
tor ( AIF ) AIF i defined a the ratio of the um of inherited attribute in al
l clae of the ytem under conideration to the total number of available att
ribute ( locally defined plu inherited ) for all clae. Polymorphim Factor
( PF ) PF i defined a the ratio of the actual number of poible different pol
ymorphic ituation for cla Ci to the maximum number of poible ditinct polym
orphic ituation for cla Ci. Coupling Factor ( CF ) CF i defined a the rati
o of the maximum poible number of coupling in the ytem to the actual number
of coupling not imputable to inheritance.
3. MOOD (Metric for Object Oriented Deign)
4. Some Traditional Metric
There are many metric that are applied to traditional functional development. T
he SATC2, from experience, ha identified three of thee metric that are applic
able to object oriented development: Complexity, Size, and Readability. To meau
re the complexity, the cyclomatic complexity i ued.
Software Aurance Technology Center (SATC) at NASA Goddard Space Flight Center
2
7. Conclusion
This paper introduces the basic metric suite for object-oriented design. The nee
d for such metrics is particularly acute when an organization is adopting a new
technology for which established practices have yet to be developed. The metric
suite is not adoptable as such and according to some other researches it is stil
l premature to begin applying such metrics while there remains uncertainty about
the precise definitions of many of the quantities to be observed and their impa
ct upon subsequent indirect metrics. For example the usefulness of the proposed
metrics, and others, would be greatly enhanced if clearer guidance concerning th
eir application to specific languages were to be provided. Metric data provides
quick feedback for software designers and managers. Analyzing and collecting the
data can predict design quality. If appropriately used, it can lead to a signif
icant reduction in costs of the overall implementation and improvements in quali
ty of the final product. The improved quality, in turn reduces future maintenanc
e efforts. Using early quality indicators based on objective empirical evidence
is therefore a realistic objective. According to my opinion its motivating for th
e developer to get early and continuous feedback about the quality in design and
implementation of the product they develop and thus get a possibility to improv
e the quality of the product as early as possible. It could be a pleasant challe
nge to improve own design practices based on measurable data. It is unlikely tha
t universally valid object-oriented quality measures and models could be devised
, so that they would suit for all languages in all development environments and
for different kind of application domains. Therefore measures and models should
be investigated and validated locally in each studied environment. It should be
also kept in mind that metrics are only guidelines and not rules. They are guide
lines that give an indication of the progress that a project has made and the qu
ality of design.
8. References:
[1] Shyam R. Chidamber, Chris F. Kemerer, A METRICS SUITE FOR OBJECT ORIENTED DE
SIGN, 1993 [2] Carnegie Mellon School of Computer Science, Object-Oriented Testi
ng & Technical Metrics, PowerPoint Presentation , 2000 [3] Sencer Sultanolu, mit K
araka, Object Oriented Metrics, Web Document, 1998 [4] Linda H. Rosenberg, Applyi
ng and Interpreting Object Oriented Metrics [5] Sencer Sultanolu, mit Karaka, Compl
exity Metrics and Models, Web Document, 1998 [6] Jaana Lindroos, Code and Design
Metrics for Object-Oriented Systems, 2004 [7] Ralf Reiing, Towards a Model for O
bject-Oriented Design Measurement [8] Magiel Bruntink, Testability of Object-Ori
ented Systems: a Metrics-based Approach, 2003 [9] Aine Mitchell, James F. Power,
Toward a definition of run-time object-oriented metrics, 2003 [10] Sencer Sulta
nolu, mit Karaka, Software Size Estimating, Web Document, 1998 [11] David N. Card,
Khaled El Emam, Betsy Scalzo, Measurement of Object-Oriented Software Developmen
t Projects, 2001