The document evaluates two metrics for exception handling: Number of Catch Blocks per Class (NCBC) and Exception Handling Factor (EHF). It applies these metrics to 5 projects. For NCBC, results show the ratio of catch blocks to possible catch blocks for each class. For EHF, it shows the ratio of unique exception classes to total possible exception classes. The NCBC metric is better as it shows exception handling at the class level, while EHF does not capture exception handling accurately. In conclusion, NCBC helps make programs more robust by allowing exception handling reuse through inheritance.
Stable and Reliable Route Identification Scheme for Efficient DSR Route Cache...
Evaluation of Exception Handling Metrics
1. IJASCSE, VOL 1, ISSUE 4, 2012
DEC. 31
Evaluation of Exception Handling Metrics
Ebrahim Awad Shided Alharbi
Teaching Assistant
Deanship of e-Learning and Distance Education
King Abdulaziz University
Jeddah, Saudi Arabia
Abstract
An exception is a problem occurs during execute a program. Exception handling enables a program to
continue executing when occurs an exception. The exception handling enables programmers to write
robust and more fault–tolerant programs. The purpose of this paper is to offer evaluation of two metrics
for exception handling (Number of Catch Blocks per Class (NCBC)) and (Exception Handling Factor).
Keywords
Exception handling; fault –tolerant; NCBC; EHF; evaluation; metrics.
I. INTRODUCTION
An exception handling allows programmers to specify the
action when an exception occurs. Exception handling can
provide software fault tolerance. Exception handling helps
the developers to make robust programs. The Java language
supports exception handling and many other languages as
C++ and C#. In this paper evaluate exception handling met-
rics: Number of Catch Blocks per Class (NCBC) and Excep- Where n= Number of Methods in a class
tion Handling Factor (EHF) on 5 projects. m = Number of existing Catch Blocks in a Method
The rest of my paper organized as follows. The Literature Cij is jth Catch Block in ith Method
review is in Section 2. Section 3 explains exception handling
metrics. Section 4 evaluates the exception handling metrics
Cik is kth Catch Block in ith Method
for five projects. Section 5 offers the conclusion. l = Number of possible Catch Blocks in a Method
II. LITERATURE REVIEW I am going to explain this metric by applying on
the next code:
Little papers talked about exception handling metrics. I
found this paper talked about exception handling metrics,
“Software Design Metrics for Object-Oriented Software”. ClassA
[1]. This research introduces a new set of design metrics for {
object-oriented code. Two metrics (Number of Catch Blocks Public int m1()// method
per Class) and (Exception Handling Factor) that measure the {
amount of robustness included in the code. Try
{
III. Exception Handling Metrics: //code
}
3.1 Number of Catch Blocks per Class (NCBC) Catch
Metric: {
//here exception handling
Number of Catch Block per Class (NCBC) metric is the
}
ratio of the catch block in a class (for each method in the
class) to the total number of possible catch blocks in a class. }
The next equation is the formal equation of this metric [1]: Public int m2(int a, int b)
{
www.ijascse.in Page 40
2. IJASCSE, VOL 1, ISSUE 4, 2012
DEC. 31
Try I am going to explain this metric by applying on the next
{ code:
}
Catch ClassA
{ {
} Public int m1()// method
{
} Try
Class B {
{ //code
Public void m3() }
{ Catch (ArithmeticException e)
Try {
{ //here exception handling
} }
Catch }
{ Public int m2(int a, int b)
} {
Try Try
{ {
} }
Catch Catch (ArrayIndexOutOfBoundsException e)
{ {
} }
} }
} Class B
Public double m4(double n1,double2) {
{ Public void m3()
Try {
{ Try
} {
Catch }
{ //Array out of bound exception
}
} Catch (ArrayIndexOutOfBoundsException e)
} {
}
Assume the number of possible catch blocks in A and B Try
is 4 and 8 respectively. The values of metric NCBC for {
classes A and B are: }
NCBC (A) = 2/4=1/2 Catch (FileNotFoundException e)
NCBC (B) = 3/8 {
}
3.2 Exception Handling Factor (EHF) Metric: }
}
Exception handling factor (EHF) metric is the ratio of the Public double m4(double n1,double2)
number of exception classes (without the number of times
{
the same exception class occurs) to the total number of pos-
Try
sible exception classes in software. The next equation is the
formal equation of this metric [1]: {
}
EHF = NumberofExceptionClasses/TotalNumberofExceptionClassesx100
www.ijascse.in Page 41
3. IJASCSE, VOL 1, ISSUE 4, 2012
DEC. 31
Catch (ArithmeticException e)
{
}
}
}
The programmers can use any exception class as an ar-
gument in multiple catch blocks but to calculate EHF we
will count it once only. Thus, Number of Exception classes =
3 and if we assume Number of possible exception classes=8
(class A and class B).Exception Handling Factor (EHF) =
3/8.
IV. EVALUATION OF EXCEPTION HANDLING
METRICS:
I do tool to Number of Catch Blocks per Class (NCBC)
metric and Exception Handling Factor (EHF) metric.
4.1 Evaluation of Number of Catch Blocks per
Class (NCBC) Metric:
I applied the metric on five projects for evaluation.
Class 1 2 3 4 5 6 7 8 9 10
Project1 0 0 0 0 0 9.091 0 0 25 -
Project4 0 20 0 0 0 50 0 - - -
Project5 37.037 57.895 33.333 12.5 - - - - - -
Project6 0 100 100 0 33.333 - - - - -
Project10 30.770 75 0 44.444 37.5 36.363 20 40.909 50 30.303
100 project1
80
NCBC
60
40
20
0
class1 class2 class3 class4 class5 class6 class7 class8 class9
classess
www.ijascse.in Page 42
4. IJASCSE, VOL 1, ISSUE 4, 2012
DEC. 31
100 project2
NCBC
50
0
classes
.
The NCBC metric is excellent metric because it appears
all exception handling for each class in the code. The Num-
ber of Catch Blocks per Class metric is excellent metric be-
cause shows all exception handling for each class in the
code. If I know any class does not handle exceptions, I will
handle exceptions in the class.
project4
100
80
60
NCBC
40
20
0
class1 class2 class3 class4 class5
classes
www.ijascse.in Page 43
5. IJASCSE, VOL 1, ISSUE 4, 2012
DEC. 31
project5
100
80
60
NCBC
40
20
0
class1 class2 class3 class4 class5 class6 class7 class8 class9 class10
classes
4.2 Evaluation of Exception Handling Factor
( EHF) metric:
I applied the metric for same five projects for evaluation.
projects Project1 Project4 Project5 Project6 Project10
EHF 0 00 16.667 0 2.831
100
80
60
EHF
40
20
0
project1 project 2 project3 project4 project5
projects
The EHF metric appears an exception handling for all the
code of a program and any exception class used as argu-
ments in multiple catch blocks we count once only. The EHF
metric is not inexact in value the exception handling of pro-
gram.
www.ijascse.in Page 44
6. IJASCSE, VOL 1, ISSUE 4, 2012
DEC. 31
V CONCLUSION:
Number of Catch Blocks per Class (NCBC) metric is bet-
ter than EHF metric because it shows exception handling for
each class in the code. The inheritance is one of the proper-
ties of Object-Oriented Programming. It allows us to reuse
the behavior of a class in the new class. Thus, the Number of
Catch Blocks per Class (NCBC) metric help us to make pro-
grams are more reliable, robust and fault-tolerance.
VI REFERENCES:
[1] K.K.Aggarwal, Yogesh Singh, Arvinder Kaur and
Ruchika Malhotra " Software Design Metrics for Object-
Oriented Software", ETH Zurich, Chair of Software Engi-
neering, Vol. 6, No. 1, January-February 2006.
[2] Saurabh Sinha and Mary Jean Harrold, "Criteria for Test-
ing Exception-Handling Constructs in Java Programs",
Software Maintenance, 1999.
[3] FLAVIU CRISTIAN," Exception Handling and Software
Fault Tolerance", IEEE TRANSACTIONS ON COMPUT-
ERS, VOL. C-31, NO. 6, JUNE 1982.
[4] N.Fenton et al, Software Metrics: A Rigorous and practi-
cal approach.International Thomson Computer Press, 1996.
[5] Lingli Zhang Chandra Krintz Priya
Nagpurkar,"Supporting Exception Handling for Futures in
Java", Computer Science Department University of Califor-
nia, Santa Barbara.
[6] Beniamino Murgante, Osvaldo Gervasi, David Taniar,"
Computational Science and Its Appilcations -- ICCSA 2009:
International Conference", Seoul, Korea, June 29--July 2,
2009, Proceedings.
www.ijascse.in Page 45