Your SlideShare is downloading. ×
Evaluation of Exception Handling Metrics
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Evaluation of Exception Handling Metrics

207
views

Published on


0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
207
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 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 ArabiaAbstract An exception is a problem occurs during execute a program. Exception handling enables a program tocontinue executing when occurs an exception. The exception handling enables programmers to writerobust 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). KeywordsException handling; fault –tolerant; NCBC; EHF; evaluation; metrics.I. INTRODUCTION An exception handling allows programmers to specify theaction when an exception occurs. Exception handling canprovide software fault tolerance. Exception handling helpsthe developers to make robust programs. The Java languagesupports exception handling and many other languages asC++ 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 classtion 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 Methodreview is in Section 2. Section 3 explains exception handlingmetrics. Section 4 evaluates the exception handling metrics Cik is kth Catch Block in ith Methodfor five projects. Section 5 offers the conclusion. l = Number of possible Catch Blocks in a MethodII. LITERATURE REVIEW I am going to explain this metric by applying on the next code: Little papers talked about exception handling metrics. Ifound 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()// methodper 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) CatchMetric: { //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 theclass) 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. 31Try I am going to explain this metric by applying on the next{ code:}Catch ClassA{ {} Public int m1()// method {} TryClass B {{ //codePublic void m3() }{ Catch (ArithmeticException e)Try {{ //here exception handling} }Catch }{ Public int m2(int a, int b)} {Try Try{ {} }Catch Catch (ArrayIndexOutOfBoundsException e){ {} }} }} Class BPublic 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 Tryis 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- Trysible exception classes in software. The next equation is theformal equation of this metric [1]: { }EHF = NumberofExceptionClasses/TotalNumberofExceptionClassesx100www.ijascse.in Page 41
  • 3. IJASCSE, VOL 1, ISSUE 4, 2012 DEC. 31Catch (ArithmeticException e){}}} The programmers can use any exception class as an ar-gument in multiple catch blocks but to calculate EHF wewill 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 perClass (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 classesswww.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 appearsall 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 thecode. If I know any class does not handle exceptions, I willhandle exceptions in the class. project4 100 80 60 NCBC 40 20 0 class1 class2 class3 class4 class5 classeswww.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 classes4.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. 31V CONCLUSION: Number of Catch Blocks per Class (NCBC) metric is bet-ter than EHF metric because it shows exception handling foreach class in the code. The inheritance is one of the proper-ties of Object-Oriented Programming. It allows us to reusethe behavior of a class in the new class. Thus, the Number ofCatch 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 andRuchika 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 SoftwareFault 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 PriyaNagpurkar,"Supporting Exception Handling for Futures inJava", 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

×