SlideShare a Scribd company logo
1 of 6
Download to read offline
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
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
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
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
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
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

More Related Content

What's hot

Oop04 6
Oop04 6Oop04 6
Oop04 6schwaa
 
IJERD (www.ijerd.com) International Journal of Engineering Research and Devel...
IJERD (www.ijerd.com) International Journal of Engineering Research and Devel...IJERD (www.ijerd.com) International Journal of Engineering Research and Devel...
IJERD (www.ijerd.com) International Journal of Engineering Research and Devel...IJERD Editor
 
06 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_0806 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_08Niit Care
 
White-box texting of (ATL) model transformations
White-box texting of (ATL) model transformationsWhite-box texting of (ATL) model transformations
White-box texting of (ATL) model transformationsJordi Cabot
 
Multi – Objective Two Stage Fuzzy Transportation Problem with Hexagonal Fuzzy...
Multi – Objective Two Stage Fuzzy Transportation Problem with Hexagonal Fuzzy...Multi – Objective Two Stage Fuzzy Transportation Problem with Hexagonal Fuzzy...
Multi – Objective Two Stage Fuzzy Transportation Problem with Hexagonal Fuzzy...IJERA Editor
 
Multiple inheritance in c++
Multiple inheritance in c++Multiple inheritance in c++
Multiple inheritance in c++Saket Pathak
 
Java - Generic programming
Java - Generic programmingJava - Generic programming
Java - Generic programmingRiccardo Cardin
 

What's hot (9)

Oop04 6
Oop04 6Oop04 6
Oop04 6
 
IJERD (www.ijerd.com) International Journal of Engineering Research and Devel...
IJERD (www.ijerd.com) International Journal of Engineering Research and Devel...IJERD (www.ijerd.com) International Journal of Engineering Research and Devel...
IJERD (www.ijerd.com) International Journal of Engineering Research and Devel...
 
06 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_0806 iec t1_s1_oo_ps_session_08
06 iec t1_s1_oo_ps_session_08
 
White-box texting of (ATL) model transformations
White-box texting of (ATL) model transformationsWhite-box texting of (ATL) model transformations
White-box texting of (ATL) model transformations
 
Er24902905
Er24902905Er24902905
Er24902905
 
Multi – Objective Two Stage Fuzzy Transportation Problem with Hexagonal Fuzzy...
Multi – Objective Two Stage Fuzzy Transportation Problem with Hexagonal Fuzzy...Multi – Objective Two Stage Fuzzy Transportation Problem with Hexagonal Fuzzy...
Multi – Objective Two Stage Fuzzy Transportation Problem with Hexagonal Fuzzy...
 
Multiple inheritance in c++
Multiple inheritance in c++Multiple inheritance in c++
Multiple inheritance in c++
 
Qno 2 (a)
Qno 2 (a)Qno 2 (a)
Qno 2 (a)
 
Java - Generic programming
Java - Generic programmingJava - Generic programming
Java - Generic programming
 

More from IJASCSE

Inter Time Series Sales Forecasting
Inter Time Series Sales ForecastingInter Time Series Sales Forecasting
Inter Time Series Sales ForecastingIJASCSE
 
Independent Component Analysis for Filtering Airwaves in Seabed Logging Appli...
Independent Component Analysis for Filtering Airwaves in Seabed Logging Appli...Independent Component Analysis for Filtering Airwaves in Seabed Logging Appli...
Independent Component Analysis for Filtering Airwaves in Seabed Logging Appli...IJASCSE
 
Enhanced Performance of Search Engine with Multitype Feature Co-Selection of ...
Enhanced Performance of Search Engine with Multitype Feature Co-Selection of ...Enhanced Performance of Search Engine with Multitype Feature Co-Selection of ...
Enhanced Performance of Search Engine with Multitype Feature Co-Selection of ...IJASCSE
 
Improving Utilization of Infrastructure Cloud
Improving Utilization of Infrastructure CloudImproving Utilization of Infrastructure Cloud
Improving Utilization of Infrastructure CloudIJASCSE
 
Four Side Distance: A New Fourier Shape Signature
Four Side Distance: A New Fourier Shape SignatureFour Side Distance: A New Fourier Shape Signature
Four Side Distance: A New Fourier Shape SignatureIJASCSE
 
Theoretical study of axially compressed Cold Formed Steel Sections
Theoretical study of axially compressed Cold Formed Steel SectionsTheoretical study of axially compressed Cold Formed Steel Sections
Theoretical study of axially compressed Cold Formed Steel SectionsIJASCSE
 
Improved Performance of Unsupervised Method by Renovated K-Means
Improved Performance of Unsupervised Method by Renovated K-MeansImproved Performance of Unsupervised Method by Renovated K-Means
Improved Performance of Unsupervised Method by Renovated K-MeansIJASCSE
 
A Study on the Effectiveness of Computer Games in Teaching and Learning
A Study on the Effectiveness of Computer Games in Teaching and LearningA Study on the Effectiveness of Computer Games in Teaching and Learning
A Study on the Effectiveness of Computer Games in Teaching and LearningIJASCSE
 
Clustering Based Lifetime Maximizing Aggregation Tree for Wireless Sensor Net...
Clustering Based Lifetime Maximizing Aggregation Tree for Wireless Sensor Net...Clustering Based Lifetime Maximizing Aggregation Tree for Wireless Sensor Net...
Clustering Based Lifetime Maximizing Aggregation Tree for Wireless Sensor Net...IJASCSE
 
Design Equation for CFRP strengthened Cold Formed Steel Channel Column Sections
Design Equation for CFRP strengthened Cold Formed Steel Channel Column SectionsDesign Equation for CFRP strengthened Cold Formed Steel Channel Column Sections
Design Equation for CFRP strengthened Cold Formed Steel Channel Column SectionsIJASCSE
 
OfdmaClosed-Form Rate Outage Probability for OFDMA Multi-Hop Broadband Wirele...
OfdmaClosed-Form Rate Outage Probability for OFDMA Multi-Hop Broadband Wirele...OfdmaClosed-Form Rate Outage Probability for OFDMA Multi-Hop Broadband Wirele...
OfdmaClosed-Form Rate Outage Probability for OFDMA Multi-Hop Broadband Wirele...IJASCSE
 
A Study on Thermal behavior of Nano film as thermal interface layer
A Study on Thermal behavior of Nano film as thermal interface layerA Study on Thermal behavior of Nano film as thermal interface layer
A Study on Thermal behavior of Nano film as thermal interface layerIJASCSE
 
Performance analysis of a model predictive unified power flow controller (MPU...
Performance analysis of a model predictive unified power flow controller (MPU...Performance analysis of a model predictive unified power flow controller (MPU...
Performance analysis of a model predictive unified power flow controller (MPU...IJASCSE
 
Synthesis and structural properties of Mg (OH)2 on RF sputtered Mg thin films...
Synthesis and structural properties of Mg (OH)2 on RF sputtered Mg thin films...Synthesis and structural properties of Mg (OH)2 on RF sputtered Mg thin films...
Synthesis and structural properties of Mg (OH)2 on RF sputtered Mg thin films...IJASCSE
 
Investigation of Integrated Rectangular SIW Filter and Rectangular Microstrip...
Investigation of Integrated Rectangular SIW Filter and Rectangular Microstrip...Investigation of Integrated Rectangular SIW Filter and Rectangular Microstrip...
Investigation of Integrated Rectangular SIW Filter and Rectangular Microstrip...IJASCSE
 
An effect of synthesis parameters on structural properties of AlN thin films ...
An effect of synthesis parameters on structural properties of AlN thin films ...An effect of synthesis parameters on structural properties of AlN thin films ...
An effect of synthesis parameters on structural properties of AlN thin films ...IJASCSE
 
Cluster-based Target Tracking and Recovery Algorithm in Wireless Sensor Network
Cluster-based Target Tracking and Recovery Algorithm in Wireless Sensor NetworkCluster-based Target Tracking and Recovery Algorithm in Wireless Sensor Network
Cluster-based Target Tracking and Recovery Algorithm in Wireless Sensor NetworkIJASCSE
 
Analysis and Design of Lead Salt PbSe/PbSrSe Single Quantum Well In the Infra...
Analysis and Design of Lead Salt PbSe/PbSrSe Single Quantum Well In the Infra...Analysis and Design of Lead Salt PbSe/PbSrSe Single Quantum Well In the Infra...
Analysis and Design of Lead Salt PbSe/PbSrSe Single Quantum Well In the Infra...IJASCSE
 
Portfolio Analysis in US stock market using Markowitz model
Portfolio Analysis in US stock market using Markowitz modelPortfolio Analysis in US stock market using Markowitz model
Portfolio Analysis in US stock market using Markowitz modelIJASCSE
 
Stable and Reliable Route Identification Scheme for Efficient DSR Route Cache...
Stable and Reliable Route Identification Scheme for Efficient DSR Route Cache...Stable and Reliable Route Identification Scheme for Efficient DSR Route Cache...
Stable and Reliable Route Identification Scheme for Efficient DSR Route Cache...IJASCSE
 

More from IJASCSE (20)

Inter Time Series Sales Forecasting
Inter Time Series Sales ForecastingInter Time Series Sales Forecasting
Inter Time Series Sales Forecasting
 
Independent Component Analysis for Filtering Airwaves in Seabed Logging Appli...
Independent Component Analysis for Filtering Airwaves in Seabed Logging Appli...Independent Component Analysis for Filtering Airwaves in Seabed Logging Appli...
Independent Component Analysis for Filtering Airwaves in Seabed Logging Appli...
 
Enhanced Performance of Search Engine with Multitype Feature Co-Selection of ...
Enhanced Performance of Search Engine with Multitype Feature Co-Selection of ...Enhanced Performance of Search Engine with Multitype Feature Co-Selection of ...
Enhanced Performance of Search Engine with Multitype Feature Co-Selection of ...
 
Improving Utilization of Infrastructure Cloud
Improving Utilization of Infrastructure CloudImproving Utilization of Infrastructure Cloud
Improving Utilization of Infrastructure Cloud
 
Four Side Distance: A New Fourier Shape Signature
Four Side Distance: A New Fourier Shape SignatureFour Side Distance: A New Fourier Shape Signature
Four Side Distance: A New Fourier Shape Signature
 
Theoretical study of axially compressed Cold Formed Steel Sections
Theoretical study of axially compressed Cold Formed Steel SectionsTheoretical study of axially compressed Cold Formed Steel Sections
Theoretical study of axially compressed Cold Formed Steel Sections
 
Improved Performance of Unsupervised Method by Renovated K-Means
Improved Performance of Unsupervised Method by Renovated K-MeansImproved Performance of Unsupervised Method by Renovated K-Means
Improved Performance of Unsupervised Method by Renovated K-Means
 
A Study on the Effectiveness of Computer Games in Teaching and Learning
A Study on the Effectiveness of Computer Games in Teaching and LearningA Study on the Effectiveness of Computer Games in Teaching and Learning
A Study on the Effectiveness of Computer Games in Teaching and Learning
 
Clustering Based Lifetime Maximizing Aggregation Tree for Wireless Sensor Net...
Clustering Based Lifetime Maximizing Aggregation Tree for Wireless Sensor Net...Clustering Based Lifetime Maximizing Aggregation Tree for Wireless Sensor Net...
Clustering Based Lifetime Maximizing Aggregation Tree for Wireless Sensor Net...
 
Design Equation for CFRP strengthened Cold Formed Steel Channel Column Sections
Design Equation for CFRP strengthened Cold Formed Steel Channel Column SectionsDesign Equation for CFRP strengthened Cold Formed Steel Channel Column Sections
Design Equation for CFRP strengthened Cold Formed Steel Channel Column Sections
 
OfdmaClosed-Form Rate Outage Probability for OFDMA Multi-Hop Broadband Wirele...
OfdmaClosed-Form Rate Outage Probability for OFDMA Multi-Hop Broadband Wirele...OfdmaClosed-Form Rate Outage Probability for OFDMA Multi-Hop Broadband Wirele...
OfdmaClosed-Form Rate Outage Probability for OFDMA Multi-Hop Broadband Wirele...
 
A Study on Thermal behavior of Nano film as thermal interface layer
A Study on Thermal behavior of Nano film as thermal interface layerA Study on Thermal behavior of Nano film as thermal interface layer
A Study on Thermal behavior of Nano film as thermal interface layer
 
Performance analysis of a model predictive unified power flow controller (MPU...
Performance analysis of a model predictive unified power flow controller (MPU...Performance analysis of a model predictive unified power flow controller (MPU...
Performance analysis of a model predictive unified power flow controller (MPU...
 
Synthesis and structural properties of Mg (OH)2 on RF sputtered Mg thin films...
Synthesis and structural properties of Mg (OH)2 on RF sputtered Mg thin films...Synthesis and structural properties of Mg (OH)2 on RF sputtered Mg thin films...
Synthesis and structural properties of Mg (OH)2 on RF sputtered Mg thin films...
 
Investigation of Integrated Rectangular SIW Filter and Rectangular Microstrip...
Investigation of Integrated Rectangular SIW Filter and Rectangular Microstrip...Investigation of Integrated Rectangular SIW Filter and Rectangular Microstrip...
Investigation of Integrated Rectangular SIW Filter and Rectangular Microstrip...
 
An effect of synthesis parameters on structural properties of AlN thin films ...
An effect of synthesis parameters on structural properties of AlN thin films ...An effect of synthesis parameters on structural properties of AlN thin films ...
An effect of synthesis parameters on structural properties of AlN thin films ...
 
Cluster-based Target Tracking and Recovery Algorithm in Wireless Sensor Network
Cluster-based Target Tracking and Recovery Algorithm in Wireless Sensor NetworkCluster-based Target Tracking and Recovery Algorithm in Wireless Sensor Network
Cluster-based Target Tracking and Recovery Algorithm in Wireless Sensor Network
 
Analysis and Design of Lead Salt PbSe/PbSrSe Single Quantum Well In the Infra...
Analysis and Design of Lead Salt PbSe/PbSrSe Single Quantum Well In the Infra...Analysis and Design of Lead Salt PbSe/PbSrSe Single Quantum Well In the Infra...
Analysis and Design of Lead Salt PbSe/PbSrSe Single Quantum Well In the Infra...
 
Portfolio Analysis in US stock market using Markowitz model
Portfolio Analysis in US stock market using Markowitz modelPortfolio Analysis in US stock market using Markowitz model
Portfolio Analysis in US stock market using Markowitz model
 
Stable and Reliable Route Identification Scheme for Efficient DSR Route Cache...
Stable and Reliable Route Identification Scheme for Efficient DSR Route Cache...Stable and Reliable Route Identification Scheme for Efficient DSR Route Cache...
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