SlideShare a Scribd company logo
Parul Gandhi & Pradeep Kumar Bhatia
International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 63
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
Parul Gandhi & Pradeep Kumar Bhatia
International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 64
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]
1
n
i
i
WMC C
=
= ∑
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].
Parul Gandhi & Pradeep Kumar Bhatia
International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 65
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:
Parul Gandhi & Pradeep Kumar Bhatia
International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 66
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:
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;
………
};
Parul Gandhi & Pradeep Kumar Bhatia
International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 67
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.
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.
template<class T>
class A
{
……
};
template<class S>
class B: public A<S>
{
……..
};
Class c
{
……
};
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 ;
}
Parul Gandhi & Pradeep Kumar Bhatia
International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 68
4.2. Metric 2: Depth of Template Tree (DTT)
The metric DTT can be defined as maximum inheritance path from the class to the
root template class. In this example class B inherits from class A and class C inherits
from class B Thus if we start the root node at level 0 the Depth of Template Tree
(DTT) will be 2.
FIGURE 4: Source code for calculating metric DTT
The greater the metric Depth of Template Tree (DTT) value, greater is the reusability
since generic programming is form of reuse.
4.3. Metric 3: Method Template Inheritance Factor (MTIF)
MTIF is defined as the ratio of the sum of the methods inherited from template classes
of the system under consideration to the total number of available methods (locally
defined plus inherited) for all classes.
MTIF= 1
1
( )
( )
n
t i
i
n
a i
i
M C
M C
=
=
∑
∑
* NO
n Total number of classes
NO Number of Objects of Template classes
MiCi Number of methods declared in class i
MtCi Number of the methods inherited from
template class i
Ma(Ci) MiCi + MtCi Total no of methods invoked
template<class T>
class A
{.....}
class B: public A
{....};
Class C :public B
{…..};
Class D
{…..}
Parul Gandhi & Pradeep Kumar Bhatia
International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 69
FIGURE 5: Source code for calculating metric MTIF
No of template inherited method =0+1 =1
No of methods declared in each class 1+1 =2
Total=3
If we create two objects of class B
MTIF=(1*2)/3=0.6
The greater the value of metric Method Template Inheritance Factor (MTIF) will result
in the increased code reusability.
4.4. Metric 4: Attribute Template Inheritance Factor (ATIF)
AIF is defined as the ratio of the sum of attributes inherited from template classes of
the system under consideration to the total number of available attributes (locally
defined plus inherited) for all classes.
ATIF= 1
1
( )
( )
n
t i
i
n
a i
i
A C
A C
=
=
∑
∑
* NO
n Total number of classes
NO Number of Objects of Template class
AiCi Number of attributes declared in class i
AtCi Number of the attributes inherited from
template class i
Aa(Ci) AiCi + AtCi Total no of attributes
accessed
template <class T>
class A
{
T large (T a, T b)
{
……
}
};
class B: public A<S>
{
S sum(S c,S d)
{
….
}
};
Parul Gandhi & Pradeep Kumar Bhatia
International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 70
FIGURE 6: Source code for calculating metric ATIF
No of template inherited attributes =0+ 2 =2
No of attributes declared in each class 2+2 =4
Total= 6
If we create two objects of class B
ATIF= (2*2)/6=0.6
The more the value of metric Attribute Template Inheritance Factor (ATIF), more will
be the code reusability.
5. DISCUSSION
The amount of function and class templates included in the system is dependent on
the number of generic constructs needed in the application. The more the value of
proposed metrics, more reusable software components are included in the projects.
Table1 shows the effect of these four independent metrics on Reusability. The
function and class templates are easier to maintain but difficult to test. The
observations made by analyzing metrics are shown below:
• The greater the metrics value, greater would be the code reusability.
• The greater the metrics value, less redundancy is involved in coding
• Experimental results show that the proposed metrics are only applicable for template
classes.
• If there are large number of function and class templates in a system, the testing and
debugging of the function and class becomes more complicated since it requires
greater level
of understanding at the part of developer.
template<class T>
class A
{
T a;
T b;
};
template<class S>
class B: public A<S>
{
S c;
S d;
};
Parul Gandhi & Pradeep Kumar Bhatia
International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 71
Name
of
metrics
Relative
value
of metrics
Implication
for
Reusability
NTC increases increases
DTT increases increases
MTIF increases increases
ATIF increases increases
TABLE 1: Relative values for metrics ideal
for Reusability Quality factor
6. CONCLUSION
As organizations implement systematic software reuse programs in an effort to
improve productivity and quality, they must be able to measure their progress and
identify the most effective reuse strategies. In this paper, we have proposes set of four
object- oriented metrics and results are analyzed based on object-oriented code. Our
work presented in this paper emphasis to proactively use template mechanism which
aid to analyze how much reusability is incorporated in the coding process and hence
increases the use of generic programming. The advantage of using these metrics is
the added insight gained about reduction in lines of code via using more generic
programming in the form of function and class templates. The metrics presented in
this paper have been found to be very useful to find the extent of reusability included
in the code in the form of class and function templates. The main objective of our work
explores the main aspect of software reusability. The most obvious extension of this
work is to analyze the degree to which these metrics correlate with managerial
performance indicators such as testing, maintenance effort and quality.
7. REFERENCES
[1] Douglas Gregor, Jaakko Jarvi, Jeremy Siek, Bjarne Stroustrup, Gabriel Dos Reis Andrew
Lumsdaine Concepts: Linguistic Support for Generic Programming in C++ OOPSLA, 2006.
[2] J. Barnard, 'A New Reusability Metric for Object-Oriented Software', Software Quality Journal,
Vol 7 no. 1, 1998.
[3] K.K.Aggarwal, Yogesh Singh, Arvinder Kaur, Ruchika Malhotra Empirical Study of Object-
Oriented Metrics, JOURNAL OF OBJECT TECHNOLOGY Vol. 5, no. 8, 2006.
[4] R.Harrison, S.J.Counsell, and R.V.Nithi, “An Evaluation of MOOD set of Object-Oriented
Software Metrics”, IEEE Trans. Software Engineering, Vol. SE-24, no.6, June, 1998, pp. 491-
496.
[5] S. R. Chidamber , C. F. Kemerer, A Metrics Suite for Object Oriented Design, IEEE
Transactions on Software Engineering, Vol .20 no..6, June 1994, pp. 476-492.
[6] W.Frakes and C.Terry, “Software Reuse: Metrics and Models”, ACM Computing Surveys, Vol.
28, no.2, June 1996, pp. 415-435
[7] F.B. Abreu,”The Mood Metric Set”, Proc. ECOOP’95 Workshop on Metrics, 1995.
Parul Gandhi & Pradeep Kumar Bhatia
International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 72
[8] J.Bieman and S.Karunanithi, “Candidate reuse metrics for Object Oriented and Ada Software”,
In Proceedings of IEEE-CS First International Software Metrics Symposium.
[9] K.K.Aggarwal, Yogesh Singh, Arvinder Kaur, Ruchika Malhotra “Software Reuse Metrics for
Object-Oriented Systems”, In Proceedings of ACIS Third International conference on Software
Engineering Research, Management and Applications, 2005.
[10] B.Henderson-sellers, Object-Oriented Metrics, Measures of Complexity, rentice
Hall,1996.
[11] Bjarne Stroustrup. The C++ Programming Language. Addison-Wesley, special edition, 2000.
[12] Lorenz, Mark and Jeff Kidd, Object-Oriented Software Metrics, Prentice-Hall, Englewood Cliffs,
N.J., 1994.
[13] McCabe & Associates, McCabe Object-Oriented Tool User's Instructions, user manual, 1994.
[14] N.E.Fenton, Software Metrics, A rigorous approach.Chapman and Hall, New York, 1991.
.

More Related Content

PDF
EFFECTIVE IMPLEMENTATION OF AGILE PRACTICES – OBJECT ORIENTED METRICS TOOL TO...
PDF
A Survey of Software Reusability
PDF
A Model To Compare The Degree Of Refactoring Opportunities Of Three Projects ...
PDF
Discreate eventsimulation idef
PDF
A STRUCTURAL APPROACH TO IMPROVE SOFTWARE DESIGN REUSABILITY
PDF
D502023439
PDF
Fuzzy Rule Base System for Software Classification
PDF
JELINSKI-MORANDA SOFTWARE RELIABILITY GROWTH MODEL: A BRIEF LITERATURE AND MO...
EFFECTIVE IMPLEMENTATION OF AGILE PRACTICES – OBJECT ORIENTED METRICS TOOL TO...
A Survey of Software Reusability
A Model To Compare The Degree Of Refactoring Opportunities Of Three Projects ...
Discreate eventsimulation idef
A STRUCTURAL APPROACH TO IMPROVE SOFTWARE DESIGN REUSABILITY
D502023439
Fuzzy Rule Base System for Software Classification
JELINSKI-MORANDA SOFTWARE RELIABILITY GROWTH MODEL: A BRIEF LITERATURE AND MO...

What's hot (18)

PDF
An Adjacent Analysis of the Parallel Programming Model Perspective: A Survey
PDF
Identifying Thresholds for Distance Design-based Direct Class Cohesion (D3C2)...
PDF
REALIZING A LOOSELY-COUPLED STUDENTS PORTAL FRAMEWORK
PDF
A New Metric for Code Readability
PDF
Ijcatr04051006
PDF
Rankingtherefactoring techniques
DOC
Cs6502 ooad-cse-vst-au-unit-v dce
PPTX
Performance analysis of machine learning approaches in software complexity pr...
PPTX
Model Manipulation for End-User Modelers
PDF
03 fauzi indonesian 9456 11nov17 edit septian
PPTX
Sources of errors in distributed development projects implications for colla...
PDF
SE-IT JAVA LAB SYLLABUS
PDF
Effect of refactoring on software quality
PDF
CS8592 Object Oriented Analysis & Design - UNIT V
PDF
Software Engineering with Objects (M363) Final Revision By Kuwait10
PDF
Evolutionary Testing Approach for Solving Path- Oriented Multivariate Problems
PDF
Integrating profiling into mde compilers
PDF
M256 Unit 1 - Software Development with Java
An Adjacent Analysis of the Parallel Programming Model Perspective: A Survey
Identifying Thresholds for Distance Design-based Direct Class Cohesion (D3C2)...
REALIZING A LOOSELY-COUPLED STUDENTS PORTAL FRAMEWORK
A New Metric for Code Readability
Ijcatr04051006
Rankingtherefactoring techniques
Cs6502 ooad-cse-vst-au-unit-v dce
Performance analysis of machine learning approaches in software complexity pr...
Model Manipulation for End-User Modelers
03 fauzi indonesian 9456 11nov17 edit septian
Sources of errors in distributed development projects implications for colla...
SE-IT JAVA LAB SYLLABUS
Effect of refactoring on software quality
CS8592 Object Oriented Analysis & Design - UNIT V
Software Engineering with Objects (M363) Final Revision By Kuwait10
Evolutionary Testing Approach for Solving Path- Oriented Multivariate Problems
Integrating profiling into mde compilers
M256 Unit 1 - Software Development with Java
Ad

Similar to Reusability Metrics for Object-Oriented System: An Alternative Approach (20)

PDF
Calculation of Reusability Matrices for Object Oriented applications
DOCX
Algorithm ExampleFor the following taskUse the random module .docx
PDF
Class quality evaluation using class quality
PDF
Class quality evaluation using class quality scorecards
PDF
FRAMEWORKS BETWEEN COMPONENTS AND OBJECTS
PDF
Ijess complimentary copy vol1issue3
PDF
Ijess complimentary copy vol1issue3
PDF
Iv2515741577
PDF
Iv2515741577
ODP
Software Measurement: Lecture 1. Measures and Metrics
PDF
Object oriented analysis and design unit- v
PDF
Identification, Analysis & Empirical Validation (IAV) of Object Oriented Desi...
PDF
Exploring the Efficiency of the Program using OOAD Metrics
PPTX
software engineering module i & ii.pptx
PDF
Oo tech
PDF
A Novel Optimization towards Higher Reliability in Predictive Modelling towar...
PDF
A FRAMEWORK STUDIO FOR COMPONENT REUSABILITY
PDF
Similar Characteristics of Internal Software Quality Attributes for Object-Or...
PPT
Software Product Measurement and Analysis in a Continuous Integration Environ...
PDF
M046056672
Calculation of Reusability Matrices for Object Oriented applications
Algorithm ExampleFor the following taskUse the random module .docx
Class quality evaluation using class quality
Class quality evaluation using class quality scorecards
FRAMEWORKS BETWEEN COMPONENTS AND OBJECTS
Ijess complimentary copy vol1issue3
Ijess complimentary copy vol1issue3
Iv2515741577
Iv2515741577
Software Measurement: Lecture 1. Measures and Metrics
Object oriented analysis and design unit- v
Identification, Analysis & Empirical Validation (IAV) of Object Oriented Desi...
Exploring the Efficiency of the Program using OOAD Metrics
software engineering module i & ii.pptx
Oo tech
A Novel Optimization towards Higher Reliability in Predictive Modelling towar...
A FRAMEWORK STUDIO FOR COMPONENT REUSABILITY
Similar Characteristics of Internal Software Quality Attributes for Object-Or...
Software Product Measurement and Analysis in a Continuous Integration Environ...
M046056672
Ad

More from Waqas Tariq (20)

PDF
The Use of Java Swing’s Components to Develop a Widget
PDF
3D Human Hand Posture Reconstruction Using a Single 2D Image
PDF
Camera as Mouse and Keyboard for Handicap Person with Troubleshooting Ability...
PDF
A Proposed Web Accessibility Framework for the Arab Disabled
PDF
Real Time Blinking Detection Based on Gabor Filter
PDF
Computer Input with Human Eyes-Only Using Two Purkinje Images Which Works in ...
PDF
Toward a More Robust Usability concept with Perceived Enjoyment in the contex...
PDF
Collaborative Learning of Organisational Knolwedge
PDF
A PNML extension for the HCI design
PDF
Development of Sign Signal Translation System Based on Altera’s FPGA DE2 Board
PDF
An overview on Advanced Research Works on Brain-Computer Interface
PDF
Exploring the Relationship Between Mobile Phone and Senior Citizens: A Malays...
PDF
Principles of Good Screen Design in Websites
PDF
Progress of Virtual Teams in Albania
PDF
Cognitive Approach Towards the Maintenance of Web-Sites Through Quality Evalu...
PDF
USEFul: A Framework to Mainstream Web Site Usability through Automated Evalua...
PDF
Robot Arm Utilized Having Meal Support System Based on Computer Input by Huma...
PDF
Dynamic Construction of Telugu Speech Corpus for Voice Enabled Text Editor
PDF
An Improved Approach for Word Ambiguity Removal
PDF
Parameters Optimization for Improving ASR Performance in Adverse Real World N...
The Use of Java Swing’s Components to Develop a Widget
3D Human Hand Posture Reconstruction Using a Single 2D Image
Camera as Mouse and Keyboard for Handicap Person with Troubleshooting Ability...
A Proposed Web Accessibility Framework for the Arab Disabled
Real Time Blinking Detection Based on Gabor Filter
Computer Input with Human Eyes-Only Using Two Purkinje Images Which Works in ...
Toward a More Robust Usability concept with Perceived Enjoyment in the contex...
Collaborative Learning of Organisational Knolwedge
A PNML extension for the HCI design
Development of Sign Signal Translation System Based on Altera’s FPGA DE2 Board
An overview on Advanced Research Works on Brain-Computer Interface
Exploring the Relationship Between Mobile Phone and Senior Citizens: A Malays...
Principles of Good Screen Design in Websites
Progress of Virtual Teams in Albania
Cognitive Approach Towards the Maintenance of Web-Sites Through Quality Evalu...
USEFul: A Framework to Mainstream Web Site Usability through Automated Evalua...
Robot Arm Utilized Having Meal Support System Based on Computer Input by Huma...
Dynamic Construction of Telugu Speech Corpus for Voice Enabled Text Editor
An Improved Approach for Word Ambiguity Removal
Parameters Optimization for Improving ASR Performance in Adverse Real World N...

Recently uploaded (20)

PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Classroom Observation Tools for Teachers
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
Complications of Minimal Access Surgery at WLH
PDF
Trump Administration's workforce development strategy
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
master seminar digital applications in india
PDF
VCE English Exam - Section C Student Revision Booklet
2.FourierTransform-ShortQuestionswithAnswers.pdf
Classroom Observation Tools for Teachers
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Complications of Minimal Access Surgery at WLH
Trump Administration's workforce development strategy
STATICS OF THE RIGID BODIES Hibbelers.pdf
Orientation - ARALprogram of Deped to the Parents.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Microbial diseases, their pathogenesis and prophylaxis
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Final Presentation General Medicine 03-08-2024.pptx
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Pharma ospi slides which help in ospi learning
O7-L3 Supply Chain Operations - ICLT Program
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
master seminar digital applications in india
VCE English Exam - Section C Student Revision Booklet

Reusability Metrics for Object-Oriented System: An Alternative Approach

  • 1. Parul Gandhi & Pradeep Kumar Bhatia International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 63 Reusability Metrics for Object-Oriented System: An Alternative Approach Parul Gandhi [email protected] Department of Computer Science & Business Administration Manav Rachna International University Faridabad, 121001, India Pradeep Kumar Bhatia [email protected] 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
  • 2. Parul Gandhi & Pradeep Kumar Bhatia International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 64 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] 1 n i i WMC C = = ∑ 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].
  • 3. Parul Gandhi & Pradeep Kumar Bhatia International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 65 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:
  • 4. Parul Gandhi & Pradeep Kumar Bhatia International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 66 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: 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; ……… };
  • 5. Parul Gandhi & Pradeep Kumar Bhatia International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 67 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. 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. template<class T> class A { …… }; template<class S> class B: public A<S> { …….. }; Class c { …… }; 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 ; }
  • 6. Parul Gandhi & Pradeep Kumar Bhatia International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 68 4.2. Metric 2: Depth of Template Tree (DTT) The metric DTT can be defined as maximum inheritance path from the class to the root template class. In this example class B inherits from class A and class C inherits from class B Thus if we start the root node at level 0 the Depth of Template Tree (DTT) will be 2. FIGURE 4: Source code for calculating metric DTT The greater the metric Depth of Template Tree (DTT) value, greater is the reusability since generic programming is form of reuse. 4.3. Metric 3: Method Template Inheritance Factor (MTIF) MTIF is defined as the ratio of the sum of the methods inherited from template classes of the system under consideration to the total number of available methods (locally defined plus inherited) for all classes. MTIF= 1 1 ( ) ( ) n t i i n a i i M C M C = = ∑ ∑ * NO n Total number of classes NO Number of Objects of Template classes MiCi Number of methods declared in class i MtCi Number of the methods inherited from template class i Ma(Ci) MiCi + MtCi Total no of methods invoked template<class T> class A {.....} class B: public A {....}; Class C :public B {…..}; Class D {…..}
  • 7. Parul Gandhi & Pradeep Kumar Bhatia International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 69 FIGURE 5: Source code for calculating metric MTIF No of template inherited method =0+1 =1 No of methods declared in each class 1+1 =2 Total=3 If we create two objects of class B MTIF=(1*2)/3=0.6 The greater the value of metric Method Template Inheritance Factor (MTIF) will result in the increased code reusability. 4.4. Metric 4: Attribute Template Inheritance Factor (ATIF) AIF is defined as the ratio of the sum of attributes inherited from template classes of the system under consideration to the total number of available attributes (locally defined plus inherited) for all classes. ATIF= 1 1 ( ) ( ) n t i i n a i i A C A C = = ∑ ∑ * NO n Total number of classes NO Number of Objects of Template class AiCi Number of attributes declared in class i AtCi Number of the attributes inherited from template class i Aa(Ci) AiCi + AtCi Total no of attributes accessed template <class T> class A { T large (T a, T b) { …… } }; class B: public A<S> { S sum(S c,S d) { …. } };
  • 8. Parul Gandhi & Pradeep Kumar Bhatia International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 70 FIGURE 6: Source code for calculating metric ATIF No of template inherited attributes =0+ 2 =2 No of attributes declared in each class 2+2 =4 Total= 6 If we create two objects of class B ATIF= (2*2)/6=0.6 The more the value of metric Attribute Template Inheritance Factor (ATIF), more will be the code reusability. 5. DISCUSSION The amount of function and class templates included in the system is dependent on the number of generic constructs needed in the application. The more the value of proposed metrics, more reusable software components are included in the projects. Table1 shows the effect of these four independent metrics on Reusability. The function and class templates are easier to maintain but difficult to test. The observations made by analyzing metrics are shown below: • The greater the metrics value, greater would be the code reusability. • The greater the metrics value, less redundancy is involved in coding • Experimental results show that the proposed metrics are only applicable for template classes. • If there are large number of function and class templates in a system, the testing and debugging of the function and class becomes more complicated since it requires greater level of understanding at the part of developer. template<class T> class A { T a; T b; }; template<class S> class B: public A<S> { S c; S d; };
  • 9. Parul Gandhi & Pradeep Kumar Bhatia International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 71 Name of metrics Relative value of metrics Implication for Reusability NTC increases increases DTT increases increases MTIF increases increases ATIF increases increases TABLE 1: Relative values for metrics ideal for Reusability Quality factor 6. CONCLUSION As organizations implement systematic software reuse programs in an effort to improve productivity and quality, they must be able to measure their progress and identify the most effective reuse strategies. In this paper, we have proposes set of four object- oriented metrics and results are analyzed based on object-oriented code. Our work presented in this paper emphasis to proactively use template mechanism which aid to analyze how much reusability is incorporated in the coding process and hence increases the use of generic programming. The advantage of using these metrics is the added insight gained about reduction in lines of code via using more generic programming in the form of function and class templates. The metrics presented in this paper have been found to be very useful to find the extent of reusability included in the code in the form of class and function templates. The main objective of our work explores the main aspect of software reusability. The most obvious extension of this work is to analyze the degree to which these metrics correlate with managerial performance indicators such as testing, maintenance effort and quality. 7. REFERENCES [1] Douglas Gregor, Jaakko Jarvi, Jeremy Siek, Bjarne Stroustrup, Gabriel Dos Reis Andrew Lumsdaine Concepts: Linguistic Support for Generic Programming in C++ OOPSLA, 2006. [2] J. Barnard, 'A New Reusability Metric for Object-Oriented Software', Software Quality Journal, Vol 7 no. 1, 1998. [3] K.K.Aggarwal, Yogesh Singh, Arvinder Kaur, Ruchika Malhotra Empirical Study of Object- Oriented Metrics, JOURNAL OF OBJECT TECHNOLOGY Vol. 5, no. 8, 2006. [4] R.Harrison, S.J.Counsell, and R.V.Nithi, “An Evaluation of MOOD set of Object-Oriented Software Metrics”, IEEE Trans. Software Engineering, Vol. SE-24, no.6, June, 1998, pp. 491- 496. [5] S. R. Chidamber , C. F. Kemerer, A Metrics Suite for Object Oriented Design, IEEE Transactions on Software Engineering, Vol .20 no..6, June 1994, pp. 476-492. [6] W.Frakes and C.Terry, “Software Reuse: Metrics and Models”, ACM Computing Surveys, Vol. 28, no.2, June 1996, pp. 415-435 [7] F.B. Abreu,”The Mood Metric Set”, Proc. ECOOP’95 Workshop on Metrics, 1995.
  • 10. Parul Gandhi & Pradeep Kumar Bhatia International Journal of Software Engineering (IJSE), Volume (1): Issue (4) 72 [8] J.Bieman and S.Karunanithi, “Candidate reuse metrics for Object Oriented and Ada Software”, In Proceedings of IEEE-CS First International Software Metrics Symposium. [9] K.K.Aggarwal, Yogesh Singh, Arvinder Kaur, Ruchika Malhotra “Software Reuse Metrics for Object-Oriented Systems”, In Proceedings of ACIS Third International conference on Software Engineering Research, Management and Applications, 2005. [10] B.Henderson-sellers, Object-Oriented Metrics, Measures of Complexity, rentice Hall,1996. [11] Bjarne Stroustrup. The C++ Programming Language. Addison-Wesley, special edition, 2000. [12] Lorenz, Mark and Jeff Kidd, Object-Oriented Software Metrics, Prentice-Hall, Englewood Cliffs, N.J., 1994. [13] McCabe & Associates, McCabe Object-Oriented Tool User's Instructions, user manual, 1994. [14] N.E.Fenton, Software Metrics, A rigorous approach.Chapman and Hall, New York, 1991. .