Sei sulla pagina 1di 11

International Journal of Computer Application

Available online on http://www.rspublication.com/ijca/ijca_index.htm

Issue 4, Volume 1 (February 2014)


ISSN: 2250-1797

A Metric for Assessing Reusability of Software Components


1

Neha Sadana, 2Surender Dhaiya, 3Manjot Singh Ahuja


1

Shivalik Institute (CSE Dept.), 9896085102.

Shivalik Institute (CSE Dept), 9729154367.

Shivalik Institute (CSE Dept), 9896134842.

ABSTRACT
Software engineering deals with the development of software systems within time to
reduce the cost and improve the development process. We make reuse of software in order to
reduce effort, time and cost and thus it increases the productivity and quality of software
programs. To check whether software or software components can be reused or not we measure
reusability of the components. Reusability depends on number of factors. Quality of these factors
can be measured with the help of software reusability metric. In this work a metric has been
proposed for measuring the reusability of software components for both procedures oriented and
object oriented methodology on the basis of coupling and cohesion. For the validation of metric a
survey has done with experts. And correlation between time-effort values calculated from survey
and reusability values calculated from proposed reusability metric has also been shown. This
correlation shows that higher the time taken to understand the software component, lower will be
the value of reusability.
Keywords: Software reuse, Software reusability, software reusability metric, cohesion metric,
coupling metric.

INTRODUCTION
Software engineering deals with the development of software with reduced cost and improved
development process. Earlier users need was limited and complexity was also too low but with
the pace of time size of the software system increased. To cope up with these complex needs,
new approaches to software development came into picture. These approaches include:
procedure oriented, object-oriented programming, component-based development, aspect-based
programming. With introduction of these approaches new methods of development were also
introduced. Adoption of these methods divided bulky codes into modules, components or classes
to reduce the complexity of the code. Beside this there was also need to reduce the effort, time
and cost so that productivity and quality of software programs can increase. Software reuse was a
solution to this. Software reuse has been a cherished goal for software engineers and is viewed as
a way to reduce development cost and improve quality. Software reuse is the use of previously
R S. Publication (rspublication.com), rspublicationhouse@gmail.com

Page 98

International Journal of Computer Application


Available online on http://www.rspublication.com/ijca/ijca_index.htm

Issue 4, Volume 1 (February 2014)


ISSN: 2250-1797

build code for building new code. Reusable software can be in the form of code, template,
function, procedure, object, routine or framework including various documents. To check that
upto what extent code is reusable, reusability of code is calculated. Reusability is the degree to
which a segment of source code can be used again to add new functions with slight or no
modification. To measure reusability, we need software metric. In this work software metric
comprises of mathematical equation which is based on factors affecting reusability of code.
In earlier studies work was done on formation of reusability metric [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
for either Object-Oriented or Procedure-Oriented approach. There was a need to form a
combined reusability metric for both the approaches. Another area of problem was the validation
of metric, as there were no standard rules or methods for this. Most of the authors proposed
metrics for reuse but no proper validation was provided by them.
In this work factors affecting reusability has been studied and with the help of studies and
surveys it has been found that cohesion [11,12,13,14] and coupling [15,16,17,18,19,20] are the
main factors that affect overall reusability of software components. A combined metric for both
Object-Oriented and Procedure-Oriented has been proposed in this work. To validate proposed
metric, survey has also been conducted with experts. To validate, correlation between time-effort
and reusability has been found and it has been observed that both are inversely proportional to
each other.
PROPOSED WORK
Proposed reusability metric comprises of cohesion and coupling metric, as these are the
most effecting factors for measuring reusability. To compose cohesion metric, parameters
affecting cohesion has been observed and are included in the metric. Similarly, coupling metric
has been composed and parameters affecting coupling are included in the metric. Cohesion and
Coupling metrics are associated to form reusability metric. In this work validation has also been
performed with the help of survey conducted with programmers. In survey programmers were
asked to note efforts in time to understand the reusability of software components on the basis of
coupling and cohesion.
Correlation has also been provided between Time-Effort on the basis of survey and Reusability
calculated from proposed metric. Effect of cohesion and coupling on reusability has also been
shown with the help of correlation and graphs. Effect of cohesion and coupling on time-effort
has also been shown
Proposed Metrics
In this work metric has been proposed for cohesion, coupling, and reusability of software
components.
Cohesion Metric
To form cohesion metric different factors has been analyzed which effect cohesion. Out of these,
some most effective factors are included in metric.
Chi = RSAi + RMNVi - RMVOi - RGVi
R S. Publication (rspublication.com), rspublicationhouse@gmail.com

Page 99

International Journal of Computer Application


Available online on http://www.rspublication.com/ijca/ijca_index.htm

Issue 4, Volume 1 (February 2014)


ISSN: 2250-1797

Where,
i = 1 to n (number of classes or methods)
Chi = Cohesion Metric
RSAi = number of attributed shared in classi / no of attributes in classi
RMNVi = number of methods in classi returning no value to other classes / total methods in
classi or functioni returning no value to the other functions.
RMVOi = number of methods returning value outside the classi / total methods in classi or
functioni returning value to other functions.
RGVi = total number of global or public variables in class i/total variables in the class i
In the proposed cohesion metric

-2 < Chi < +2

Coupling Metric
To form coupling metric different factors has been analyzed which effect coupling between two
classes or modules. Out of these, some most effective factors are included in metric.
Coi = RSVi + RSFi - ICi
Where,
i = 1 to n (number of classes or methods)
Coi = Cohesion Metric
RSVi = total shared variable in class i or module i / no. of variables in class i or module i
RSFi = total shared functions/public functions in class i or module i / total no of functions in class
i or module i
ICi = coupling due to inheritance,(if Ci inherits Cj then 1 else 0)
In proposed coupling metric

0 < Coi < 3

Reusability Metric
In proposed reusability metric Cohesion is divided by Coupling. That is:
Ri = k* Chi / Coi
Where, k is a constant and its value is 1
Division in the metric has been done because of the effect that cohesion and coupling put on
reusability. In this, cohesion is divided by coupling because coupling has inverse effect on
reusability and cohesion is directly proportional to reusability.
RESULTS AND VALIDATION
For showing results, one program for Object-Oriented and one program for Procedure-Oriented
have been taken. First we are taking an example for procedure oriented program.

R S. Publication (rspublication.com), rspublicationhouse@gmail.com

Page 100

International Journal of Computer Application


Available online on http://www.rspublication.com/ijca/ijca_index.htm

Issue 4, Volume 1 (February 2014)


ISSN: 2250-1797

Example: 1
Table: 1 is showing results calculated from metrics.

Program modules/Classes

Cohesion Coupling Reusability

Main
Generate_Armstrong

1
0.8

0
0.2

Find_npr

-1.6

0.6

Find_ncr
GCD
Calculate_LCM_HCF
Display_pascal
Display_floyd_triangle
Frequency_chars
Upper_String
Lower_string
Sort_String
Substring
Concatenate_string

-1.6
-2
0
0.66
0.75
1
0
0
0.86
0.4
0

0.6
1
1
0.33
0.25
0
1
1
0.14
0.6
1

20
4
2.666666667
2.666666667
-2
0
2
3
20
0
0
6.142857143
0.666666667
0

Table: 1

Table:2 shows values of Time-Effort from survey.


Program modules/classes
Main
Generate_Armstrong
Find_npr
Find_ncr
GCD
Calculate_LCM_HCF
Display_pascal
Display_floyd_triangle
Frequency_chars
Upper_String
Lower_string
Sort_String
Substring
Concatenate_string

Time Effort
2
3
6
3
5
8
4
5
2
7
8
2
6
7

Table: 2

R S. Publication (rspublication.com), rspublicationhouse@gmail.com

Page 101

International Journal of Computer Application


Available online on http://www.rspublication.com/ijca/ijca_index.htm

Issue 4, Volume 1 (February 2014)


ISSN: 2250-1797

Following are the graphs which are obtained from the tables constructed for program 1 from
metric calculations and survey.
Cohesion / Reusability
25

cohesion

Reusability

20
15
10
5
0
1

-5

10 11 12 13 14

Figure: 2

From Figure:2 it can be seen that as value of cohesion is increasing, value of reusability is also
increasing. Therefore it can be said that if there is high cohesion in software components there
will be high reusability of software components. Correlation between Cohesion and Reusability
is 0.645789995
In Figure:3, relation between coupling and reusability is shown. It can be observed from the
graph that as coupling is increasing, reusability is decreasing and as coupling is decreasing,
reusability is increasing. So, it can be concluded that low coupling leads to high reusability.
Correlation between Coupling and Reusability is -0.741360998
Coupling / Reusability
25

Coupling

20
Reusability

15
10
5
0
-5

10 11 12 13 14

Figure: 3

In Figure: 4 relations between time-effort from survey and reusability from metric has been
shown.

R S. Publication (rspublication.com), rspublicationhouse@gmail.com

Page 102

International Journal of Computer Application


Available online on http://www.rspublication.com/ijca/ijca_index.htm

Issue 4, Volume 1 (February 2014)


ISSN: 2250-1797

Time-Effort / Reusability
25
20
15
10
5
0
-5

Time-Effort (In Minutes) from Survey

Reusability

10 11 12 13 14

Figure: 4

From graph in Figure: 4, it can be observed that with increase in time-effort, reusability is
decreasing and with decrease in time-effort, reusability is increasing. This means that as time
effort is increasing for understanding a software component, reusability is decreasing.
Correlation between Time-Effort and Reusability is -0.646204463
In Figure: 5 relation between cohesion and time-effort is shown and Correlation between
Cohesion and Time-Effort is -0.298420587
Cohesion / Time-Effort
10

cohesion

Time-Effort (In Minutes) from Survey

5
0
1

10

11

12

13

14

-5
Figure: 5

In Figure:6, relation between coupling and time-effort has be shown and correlation between
Coupling and Time-Effort is 0.870025861
Coupling / Time-Effort
10

Coupling

Time-Effort (In Minutes) from Survey

0
1

10 11 12 13 14

Figure: 6

R S. Publication (rspublication.com), rspublicationhouse@gmail.com

Page 103

International Journal of Computer Application


Available online on http://www.rspublication.com/ijca/ijca_index.htm

Issue 4, Volume 1 (February 2014)


ISSN: 2250-1797

Example: 2
Table: 3 shows results from metric calculation of program 2 for object oriented.
Program
class/module
A
B
C
D
E
F

Cohesion Coupling Reusability


1.34
1.34
1.34
1
1
1
Table: 3

1.66
2.66
2.66
3
3
2

0.807229
0.503759
0.503759
0.333333
0.333333
0.5

Table: 4 show values of Time-Effort from survey.


Program
Class/Module
A
B
C
D
E
F

Time Effort
5
8
6
9
7
4

Table: 4

Following are the graphs which are obtained from the tables constructed for program 2 from
metric calculations and survey.
Cohesion / Reusability
1.5

Cohesion

Reusability

1
0.5
0
1

Figure: 8

From Figure: 8, it can be seen that when value of cohesion is high, value of reusability is also
high and when value of cohesion is decreasing, reusability is also decreasing. Therefore it can be
said that if there is high cohesion in software components there will be high reusability of
software components. Correlation between Cohesion and Reusability is 0.683329088

R S. Publication (rspublication.com), rspublicationhouse@gmail.com

Page 104

International Journal of Computer Application


Available online on http://www.rspublication.com/ijca/ijca_index.htm

Issue 4, Volume 1 (February 2014)


ISSN: 2250-1797

In Figure: 9, relation between coupling and reusability is shown. It can be observed from the
graph that as coupling is increasing, reusability is decreasing and as coupling is decreasing,
reusability is increasing. So, it can be concluded that low coupling leads to high reusability.
Correlation between Coupling and Reusability is -0.891275183
Coupling / Reusability
3.5
3
2.5
2
1.5
1
0.5
0

Coupling

Reusability

Figure: 9

In Figure: 10, relation between time-effort from survey and reusability from metric has been
shown.
Time-Effort / Reusability
10

Time-Effort (In Minutes) from Survey

Reusability

8
6
4
2
0
1

Figure: 10

From graph in Figure: 10, it can be observed that with increase in time-effort, reusability is
decreasing and with decrease in time-effort, reusability is increasing. This means that as time
effort is increasing for understanding a software component, reusability is decreasing.
Correlation between Time-Effort and Reusability is -0.590890808
In Figure: 11 relation between cohesion and time-effort is shown and correlation between
Cohesion and Time-Effort is -0.097590007

R S. Publication (rspublication.com), rspublicationhouse@gmail.com

Page 105

International Journal of Computer Application


Available online on http://www.rspublication.com/ijca/ijca_index.htm

Issue 4, Volume 1 (February 2014)


ISSN: 2250-1797

Cohesion / Time-Effort

10

Cohesion

Time-Effort (In Minutes) from Survey

0
1

Figure: 11
In Figure: 12, relation between coupling and time-effort has be shown and correlation between
Coupling and Time-Effort is 0.812080033
Coupling / Time-Effort

10

Coupling

Time-Effort (In Minutes) from Survey

0
1

Figure: 12
RESULT ANALYSIS
From the survey it can be seen that both coupling and cohesion have effect on reusability of
software component, but from the metric calculations and results it can be seen that how these
two effect reusability, and it can be observed from the results in upper section.
Relation between Time-Effort and Reusability has been shown and it is observed that if time and
effort to understand a component increases reusability decreases. Graph has also been plotted
between cohesion, coupling and time-effort, and it has been observed that coupling have high
effect on reusability rather than cohesion.
CONCLUSION
From the study it has been concluded that software reuse is important factor to be included in
software engineering process. Inclusion of reuse can improve the quality of software with
reduced time and effort. Reusability is a measure to determine the degree of reuse and reusability
depends on number of factors. In this work cohesion and coupling are found to be the most
effective factors, so, work has been done on these. So, cohesion and coupling metric has been
formed and are then combined to form reusability metric. Reusability metric tells us that upto
what extent we are able to use that software component, as finding the extent of reusability is an
important factor for the improvement of quality and reduction of time-effort.
R S. Publication (rspublication.com), rspublicationhouse@gmail.com

Page 106

International Journal of Computer Application


Available online on http://www.rspublication.com/ijca/ijca_index.htm

Issue 4, Volume 1 (February 2014)


ISSN: 2250-1797

As far as results are concerned, it has been concluded that value of reusability increases with
increase in cohesion value and reusability decreases with increase in coupling value. So, to verify
this, correlation has been found between reusability and coupling (i.e. negative correlation) and
correlation between reusability and cohesion (i.e. positive). After comparing the results from
proposed metric and results from survey it has been concluded that higher the time-effort value
to understand the program lower will be the reusability of software component. And to verify
this correlation has been found between timeeffort and reusability (i.e. negative).

REFRENCES
[1]

[2]
[3]
[4]
[5]
[6]
[7]

[8]
[9]
[10]

[11]
[12]
[13]
[14]

[15]

Matsumoto Yoshihiro, Some Experience in Promoting Reusable Software Presentation in


Higher Abstraction Levels, IEEE Transactions on Software Engineering, Vol. 10(5),
September1984, pp. 502-513
Woodfield, Scott N., David W. Embley, and Del T. Scott, Can Programmers Reuse
Software, IEEE Software, Vol. 4(7), July 1987, pp.168-175.
Prieto-Diaz, Ruben and Peter Freeman, Classifying Software for Reusability, IEEE
Software,Vol. 4(1), January 1987, pp. 6-16
Selby, Richard W., Quantitative Studies of Software Reuse, Software Reusability, Volume
II
Chen, Deng-Jyi and P.J.Lee, On the Study of Software Reuse Using Reusable C++
Components, Journal of Systems Software Vol.20(1), Jan 1993, pp. 19-36.
Caldiera, Gianluigi and Victor R. Basili, Identifying and Qualifying Reusable Sofware
Components, IEEE Software, Vol. 24(2), February1991, pp. 61-70.
Y. Lee and K.H. Chang, Reusability and maintainability metrics for object-oriented
software, Proceedings of the 38thannual on Southeast regional conference (ACM-SE
38),ACM, New York, NY, USA, 2000, pp.88-94.
Hislop, Gregory W., Using Existing Software in a Software Reuse Initiative, The Sixth
Annual Workshop on Software Reuse (WISR'93), 2-4 November 1993, Owego, New York.
Gui and scott, Measuring Software Component Reusability by Coupling and Cohesion
Metrics, JOURNAL OF COMPUTERS, VOL. 4, NO. 9, SEPTEMBER 2009
Gill and S. Sikka, Inheritance Hierarchy Based Reuse &Reusability Metrics in OOSD,
International Journal on Computer Science and Engineering (IJCSE), vol.3, June2011,
pp.2300-2309.
Shyam R. Chidamber, and Chsis F. Kemerer, A Metrics Suite For Object Oriented Design,
IEEE Transactions On Software Engineering, 20(6)(1994), pp. 476 493
Amandeep Kaur and Puneet Jai Kaur, Class Cohesion Metric in Object Oriented Systems,
International Journal of Software and Web Sciences.
Andrian Marcus, Denys Poshyvanyk, The Conceptual Cohesion of Classes, Software
Maintenance, 2005. ICSM'05. Proceedings of the 21st IEEE International Conference
Ankita Mann, Sandeep Dalal, Neetu Dabas, Measurement of Design Complexity of
Different types of Inheritance using Cohesion Metrics, International Journal of Computer
Applications (0975 8887) Volume 77 No.3, September 2013
Briand, L., Devanbu, W., Melo W.; (1997), An investigation into coupling measures for
C++, 19th International Conference on Software Engineering, page(s): 412-421, Boston,
USA.

R S. Publication (rspublication.com), rspublicationhouse@gmail.com

Page 107

International Journal of Computer Application


Available online on http://www.rspublication.com/ijca/ijca_index.htm

Issue 4, Volume 1 (February 2014)


ISSN: 2250-1797

[16] G. Myers, Composite/Structured Design, Van Nostrand Reinhold Company, New York,
1978.
[17] Page Jones, The Practical guide to structured System design, YOURDON press, Newyork
NY 1980.
[18] N. E. Fenton and S. L. Pfleeger, Software Metrics: A Rigorous & Practical Approach 2nd
edn. Reading, 1997.
[19] A. J. Offut, M.J. Harrold, and P. Kotle, A Software Metric System for Module Coupling,
Journal of System and Software, 20(3)(1993), pp. 295308.
[20] H. Dhama, Quantitative Models of Cohesion and Coupling in Software, Journal of System
and Software, 9(1)(1995), pp. 6574.

R S. Publication (rspublication.com), rspublicationhouse@gmail.com

Page 108

Potrebbero piacerti anche