International Journal of
Software Engineering (IJSE)
Volume 1, Issue 4, 2010
Edited By
Computer Science Journals
www.cscjournals.org
International Journal of Software Engineering
(IJSE)
Book: 2010 Volume 1, Issue 4
Publishing Date: 20-12-2010
Proceedings
ISSN (Online): 2180-1320
This work is subjected to copyright. All rights are reserved whether the whole or
part of the material is concerned, specifically the rights of translation, reprinting,
re-use of illusions, recitation, broadcasting, reproduction on microfilms or in any
other way, and storage in data banks. Duplication of this publication of parts
thereof is permitted only under the provision of the copyright law 1965, in its
current version, and permission of use must always be obtained from CSC
Publishers. Violations are liable to prosecution under the copyright law.
IJSE Journal is a part of CSC Publishers
http://www.cscjournals.org
© IJSE Journal
Published in Malaysia
Typesetting: Camera-ready by author, data conversation by CSC Publishing
Services – CSC Journals, Malaysia
CSC Publishers
Editorial Preface
The International Journal of Software Engineering (IJSE) provides a forum for software
engineering research that publishes empirical results relevant to both researchers and
practitioners. It is the fourth issue of First volume of IJSE and it is published bi-monthly,
with papers being peer reviewed to high international standards.
IJSE encourage researchers, practitioners, and developers to submit research papers
reporting original research results, technology trend surveys reviewing an area of
research in software engineering, software science, theoretical software engineering,
computational intelligence, and knowledge engineering, survey articles surveying a broad
area in software engineering and knowledge engineering, tool reviews and book reviews.
Some important topics covered by IJSE usually involve the study on collection and
analysis of data and experience that can be used to characterize, evaluate and reveal
relationships between software development deliverables, practices, and technologies.
IJSE is a refereed journal that promotes the publication of industry-relevant research, to
address the significant gap between research and practice.
Table of Content
Volume 1, Issue 4, December 2010
Pages
63-72 Reusability Metrics for Object-Oriented System: An Alternative
Approach
Parul Gandhi, Pradeep Kumar Bhatia
International Journal of Software Engineering (IJSE) Volume (1) Issue (4)
Parul Gandhi & Pradeep Kumar Bhatia
Reusability Metrics for Object-Oriented System: An Alternative
Approach
Parul Gandhi
gandhi2110@gmail.com
Department of Computer Science & Business Administration
Manav Rachna International University
Faridabad, 121001, India
Pradeep Kumar Bhatia
pk_bhatia2002@yahoo.com
Department of Computer Science & Engineering
G. J. Universityof Science and Technology
Hisar, 125001, India
Abstract
Object-oriented metrics plays an import role in ensuring the desired quality and have
widely been applied to practical software projects. The benefits of object-oriented
software development increasing leading to development of new measurement
techniques. Assessing the reusability is more and more of a necessity. Reusability is
the key element to reduce the cost and improve the quality of the software. Generic
programming helps us to achieve the concept of reusability through C++ Templates
which helps in developing reusable software modules and also identify effectiveness
of this reuse strategy. The advantage of defining metrics for templates is the
possibility to measure the reusability of software component and to identify the most
effective reuse strategy. The need for such metrics is particularly useful when an
organization is adopting a new technology, for which established practices have yet to
be developed. Many researchers have done research on reusability metrics [2, 9, 3,
4]. In this paper we have proposed four new independent metrics Number of Template
Children (NTC), Depth of Template Tree (DTT) Method Template Inheritance Factor
(MTIF) and Attribute Template Inheritance Factor (ATIF), to measure the reusability
for object-oriented systems.
Keywords: Object-Oriented Metrics, Reusability, Generic Programming, Template, Inheritance.
1. INTRODUCTION
Reuse of existing software components increase the quality and productivity in
software development and maintenance. Software reuse reduces the amount of
software that needs to be produced from scratch and hence less testing time for new
software. Industrial observers suggest that a reuse strategy could save up to 20% of
development costs [10]. With reuse, software development becomes a capital
investment. C++ templates are used to support the concept of reusability in object-
oriented programming. An object-oriented software system is a collection of classes
which are abstract data types and templates are a way of making classes more
abstract without actually knowing what data type will be handled by the operations of
International Journal of Software Engineering (IJSE), Volume (1): Issue (4)
63
Parul Gandhi & Pradeep Kumar Bhatia
the class. The ability to have a single class that can handle several different data
types means the code is easier to maintain, and it makes classes more reusable. This
raises questions about how generic programming included in the form of templates in
the code can be measured to identify effectiveness of this reuse strategy. The
measurement of reuse would help developers to monitor current levels of reuse and
provide insight in developing software that is easily reused. In this paper, four metrics
are proposed to measure amount of reusability included in the form of templates.
Reuse can be classified in one of the following ways: public/private, verbatim
/generic/leveraged, and direct/indirect. Public reuse is reuse of externally constructed
software while private reuse is reuse of software within a product [14]. We will
continue our study based on object-oriented metrics suite given by Chidamber and
Kamerer[5] and the MOOD metric suite[7]. Among the Chidamber and Kamerer metric
suite the most significant metrics for reusability are Depth of Inheritance Tree (DIT),
which indicates the length of inheritance [8] and Number of Children (NOC) which
indicates the width. Method Inheritance factor (MIF) and Attribute Inheritance factor
also indicates the reusability [7, 4]. Our main focus of this work is on using these
metrics to evaluate the characteristic of template classes which helps in developing
reusable software.
2. OO METRICS- AN OVERVIEW
OO Metrics play an important role in ensuring the desired quality and productivity of
the software project. To ensure the quality of the OO software many researchers have
proposed metrics suite [9, 5, 6]. The main metrics for OO software are briefly
described below [5].
Metric 1: Weighted Method Per Class (WMC) is the number of methods defined in
class. WMC is used to predict time and effort required to develop and maintain the
class. Classes with many methods are more application specific which limits the
possibility of reuse It can be defined as referred from[5]
n
WMC =
C
∑
i
i 1
=
Where
• n No of methods defined in a class
• Ci Complexity of method i
Metric 2: Depth of Inheritance tree (DIT) can be defined as maximum inheritance
path from the class to the root class. The deeper a class is in the hierarchy, the
greater the number of methods it is likely to inherit, making it more complex. As a
positive factor, deep trees increase reusability because of inheritance feature[5].
Metric 3: Number of Children (NOC) can be defined as number of immediate sub-
classes of a class. NOC measures the breadth of a class hierarchy. Higher the value
of NOC , fewer the faults, which is desirable[5]. NOC, therefore, primarily evaluates
efficiency, reusability, and testability [8, 12,13].
International Journal of Software Engineering (IJSE), Volume (1): Issue (4)
64
Parul Gandhi & Pradeep Kumar Bhatia
Metric 4: Coupling Between Object (CBO) can be defined as number of classes to
which a class is coupled. Two classes are coupled when methods declared in one
class use methods or instance variables defined by the other class [5].
Metric 5: Response for a Class (RFC) can be defined as set of methods that can
potentially be executed in response to a message received by an object of that class.
Large RFC indicate more faults. Classes with high RFC become more complex and
their testing become more complicated [5].
Metric 6: Lack of Cohesion of Methods (LCOM) indicates the lack of cohesion of
methods. Given n methods M1, M2, …, Mn contained in a class C1 which also contains
a set of instance variables {Ii} . Then for any method Mi we can define the partitioned
set of [5]
P = {(Ii, Ij) | Ii ∩ Ij = φ} and Q = {(Ii, Ij) | Ii ∩ Ij ≠ φ}
then LCOM = |P| - |Q|, if |P| > |Q|
=0 otherwise
3. GENERIC PROGRAMMING WITH TEMPLATE - AN OVERVIEW
Templates are useful feature of object- oriented programming to implement generic
constructs which can be used with any arbitrary type. Templates can be used to
create a family of classes and functions. C++ templates provide a way to re-use
source code as opposed to inheritance. With the help of template a single class can
be used to handle different types of data and a single function can be used to accept
different types of data which makes the code easier to maintain and classes more
reusable. templates provide sufficient information to a compiler’s optimizers
(especially the inliner) to generate code that is optimal in both time and space[1].
Templates can be classified into two categories: Class Templates and Function
Templates.
3.1 Class Template
Class Templates allow the classes to operate with generic type. These classes are
generic type and member function of these classes can operate on different data
types. This will overcome the limitation of classes to hold objects of any particular data
type. The following class template shown in Figure 1 illustrates how the complier
handles creation of objects using class template:
International Journal of Software Engineering (IJSE), Volume (1): Issue (4)
65
Parul Gandhi & Pradeep Kumar Bhatia
template <class T1, class t2>
class Sample
{
T1 a;
T2 b;
………
};
/*when objects of templates class are created using the
following statements Sample <int, float>s*/
/*The compiler creates the following class sample with two
data members one is of int type and other is of float type*/
class sample
{
int a;
float b;
………
};
FIGURE 1: Source Code for Class Template
3.2 Function Template
The C++ language [11] supports parameterized types and functions in the form of
templates. With the help of templates the programmer can declare group of functions
that works for all data types. Function Templates compactly and conveniently perform
identical operations for each type of data compactly and conveniently. Based on the
argument types provided in calls to the function, the compiler automatically
instantiates separate object code functions to handle each type of call appropriately.
The main advantage of generic function is that they overcome the limitation of general
function which operates only on a particular data type. The following Function
template shown in Figure2 illustrates how the complier handles creation of functions
using function template:
International Journal of Software Engineering (IJSE), Volume (1): Issue (4)
66
Parul Gandhi & Pradeep Kumar Bhatia
template <class T>
T large (T a, T b}
{
return a > b ? a : b ;
}
// Function can be called as follows
int a,c=5,d=4;
a=large(c,d);
/*The compiler creates the following
function for data type int:*/
int large (int a, int b)
{
return a > b ? a : b ;
}
FIGURE 2: Source Code for Function Templates
4. PROPOSED METRICS
In this section we have proposed four independent metrics and illustrate their use by
computing their values on example source code.
4.1. Metric 1: Number of Template Children (NTC)
The metric NTC can be defined as number of immediate sub-classes of a Template
class.
template<class T>
class A
{
……
};
template<class S>
class B: public A<S>
{
……..
};
Class c
{
……
};
FIGURE 3: Source code for calculating metric NTC
In this example there is one class B which inherits from a template class A therefore
Number of Template Children (NTC) is 1. The more the value of metric Number of
Template Children (NTC), more reusable software components are included in the
projects.
International Journal of Software Engineering (IJSE), Volume (1): Issue (4)
67
Add New Comment