Sei sulla pagina 1di 6

DEC.

31

IJASCSE, VOL 1, ISSUE 4, 2012

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 faulttolerant 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 metrics: Number of Catch Blocks per Class (NCBC) and Exception Handling Factor (EHF) on 5 projects. The rest of my paper organized as follows. The Literature review is in Section 2. Section 3 explains exception handling metrics. Section 4 evaluates the exception handling metrics for five projects. Section 5 offers the conclusion.
II.

Where n= Number of Methods in a class m = Number of existing Catch Blocks in a Method Cij is jth Catch Block in ith Method Cik is kth Catch Block in ith Method l = Number of possible Catch Blocks in a Method I am going to explain this metric by applying on the next code:
ClassA { Public int m1()// method { Try { //code } Catch { //here exception handling } } Public int m2(int a, int b) {

LITERATURE REVIEW

Little papers talked about exception handling metrics. I found this paper talked about exception handling metrics, Software Design Metrics for Object-Oriented Software. [1]. This research introduces a new set of design metrics for object-oriented code. Two metrics (Number of Catch Blocks per Class) and (Exception Handling Factor) that measure the amount of robustness included in the code.

III. Exception Handling Metrics: 3.1 Number of Catch Blocks per Class (NCBC) Metric:
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]:

www.ijascse.in

Page 40

DEC. 31
Try { } Catch { } } Class B { Public void m3() { Try { } Catch { } Try { } Catch { } } } Public double m4(double n1,double2) { Try { } Catch { } } }

IJASCSE, VOL 1, ISSUE 4, 2012

I am going to explain this metric by applying on the next code:


ClassA { Public int m1()// method { Try { //code } Catch (ArithmeticException e) { //here exception handling } } Public int m2(int a, int b) { Try { } Catch (ArrayIndexOutOfBoundsException e) { } } Class B { Public void m3() { Try { } //Array out of bound exception Catch (ArrayIndexOutOfBoundsException e) { } Try { } Catch (FileNotFoundException e) { } } } Public double m4(double n1,double2) { Try { }

Assume the number of possible catch blocks in A and B is 4 and 8 respectively. The values of metric NCBC for classes A and B are: NCBC (A) = 2/4=1/2 NCBC (B) = 3/8

3.2 Exception Handling Factor (EHF) Metric:


Exception handling factor (EHF) metric is the ratio of the number of exception classes (without the number of times the same exception class occurs) to the total number of possible exception classes in software. The next equation is the formal equation of this metric [1]:
EHF = NumberofExceptionClasses/TotalNumberofExceptionClassesx100

www.ijascse.in

Page 41

DEC. 31
Catch (ArithmeticException e) { } } }

IJASCSE, VOL 1, ISSUE 4, 2012

The programmers can use any exception class as an argument 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 METRICS:

OF

EXCEPTION

HANDLING

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

10

Project1

9.091

25

Project4

20

50

Project5

37.037

57.895

33.333

12.5

Project6

100

100

33.333

Project10

30.770

75

44.444

37.5

36.363

20

40.909

50

30.303

100 80 60 40 20 0

project1

NCBC

class1 class2 class3 class4 class5 class6 class7 class8 class9

classess

www.ijascse.in

Page 42

DEC. 31

IJASCSE, VOL 1, ISSUE 4, 2012

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 Number of Catch Blocks per Class metric is excellent metric because 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

NCBC

60 40 20 0

class1

class2

class3
classes

class4

class5

www.ijascse.in

Page 43

DEC. 31

IJASCSE, VOL 1, ISSUE 4, 2012

project5
100 80
NCBC

60

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

00

16.667

2.831

100
80
EHF

60
40

20
0

project1

project 2

project3
projects

project4

project5

The EHF metric appears an exception handling for all the code of a program and any exception class used as arguments in multiple catch blocks we count once only. The EHF metric is not inexact in value the exception handling of program.

www.ijascse.in

Page 44

DEC. 31

IJASCSE, VOL 1, ISSUE 4, 2012

CONCLUSION:

Number of Catch Blocks per Class (NCBC) metric is better than EHF metric because it shows exception handling for each class in the code. The inheritance is one of the properties 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 programs are more reliable, robust and fault-tolerance.

VI REFERENCES:
[1] K.K.Aggarwal, Yogesh Singh, Arvinder Kaur and Ruchika Malhotra " Software Design Metrics for ObjectOriented Software", ETH Zurich, Chair of Software Engineering, Vol. 6, No. 1, January-February 2006. [2] Saurabh Sinha and Mary Jean Harrold, "Criteria for Testing Exception-Handling Constructs in Java Programs", Software Maintenance, 1999. [3] FLAVIU CRISTIAN," Exception Handling and Software Fault Tolerance", IEEE TRANSACTIONS ON COMPUTERS, VOL. C-31, NO. 6, JUNE 1982. [4] N.Fenton et al, Software Metrics: A Rigorous and practical 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 California, 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

Potrebbero piacerti anche