Results 1 to 9 of 9
  1. #1

    Default Handling Exceptionsin Java, C, C++, Objective-C


    Anybody post your experiences in handling exceptions of the following languages,

    Java

    C

    C++

    Objective-C

    What are the pros and cons on each of the above programming language.

  2. #2
    Junior Member
    Join Date
    Jun 2009
    Gender
    Male
    Posts
    478
    Why do you need to know?

  3. #3
    For my research...

  4. #4
    sayuha sa assignment bai? hehehe..

    bitaw, pros of handling exceptions is you can continue with your code despite encountering any error which are not necessary, sometimes they do. These errors would quit the running program kung wala nimo gi-handle ang exceptions, mo-runtime error.

    Cons, kung naa ka'y null value, and required sa lain nga function, you'll gonna have a bad time, especially, kung dili nimo ma-trace..

  5. #5
    @stealthghost: Thanks for the reply. This is not an assignment but a narrative research regarding the comparative studies on handling exception in most popular programming language. Choosing the above programming languages above is through the TIOBE programming language popularity community index.

    I am not taking answers from student who do not have a solid experience in programming, what I need is the input from an experience programmer who does actual coding specifically in handling exceptions mechanism.

    Programmers around the world experience problems with error trapping in how, when and where to apply the available exception handling in every programming language.

    As a software engineer I have some but need to know other experiences for my research regarding this matter.
    Last edited by chrisvil; 06-05-2014 at 11:44 AM. Reason: Updates

  6. #6
    Junior Member
    Join Date
    Jun 2009
    Gender
    Male
    Posts
    478
    Quote Originally Posted by chrisvil View Post
    @stealthghost: Thanks for the reply. This is not an assignment but a narrative research regarding the comparative studies on handling exception in most popular programming language. Choosing the above programming languages above is through the TIOBE programming language popularity community index.

    I am not taking answers from student who do not have a solid experience in programming, what I need is the input from an experience programmer who does actual coding specifically in handling exceptions mechanism.

    Programmers around the world experience problems with error trapping in how, when and where to apply the available exception handling in every programming language.

    As a software engineer I have some but need to know other experiences for my research regarding this matter.

    This should be in your original question, for us to know the context on why do you ask.

    Also, you should share what you know at hand so that answers will not be duplicated.

    Probably im not experienced as what you have described but maybe we can add or maybe debate about general practice.

    --------------

    As far as i know, Java or .net are richest built-in exception handling because of the checked|unchecked exception handling.

    C++ doesnt have checked (maybe with the new C++ spec); it has unchecked exception handling

    C doesnt have exception handling built-in aside from if-else (maybe with the new spec).

    Objective-C have exception unchecked handling; not sure with unchecked (anyone?)

    As you can see, most of them have built-in exception handling, so the language dont have issue.

    I think the better queston is what are the general practice.

    My general practice are:

    We should write method with unchecked exceptions aka runtime exception that are thrown when you have system outage like Database down, NullPointerException, Network is down or File system is down should be re-thrown. These are the exceptions that the users cannot do anything about it, meant to be ignored and just log.

    To handle unchecked exception is, ideally, you shouldnt handle it, just let the system rethrow it until it reaches to the end of the stack of app server who is invoking it (e.g. jboss/tomcat/jetty or application server), and the app server itself should have feedback to the client (system or user) about the system failure (error=500), or maybe alert to the admins/operators so that it will have have manual intervention.


    We should write method with checked exception if it's an exception related to the business logic such as ZeroDivisorException, LowBalanceException, LowFuelExcepton, InvalidPasswordException. It means they are exceptions that user can do anything about why it's happening and avoid inputting those invalid values.

    To handle the checked exception, the client program that uses methods with checked exception are required to handle it. For example:

    Code:
     public String authenticate(String user, String password) throws InvalidPassWordExcepton  {
         // blah
         return token;
      }
    
    
     public void doSomething(String
      try {
        String token = authenticate(user, password);    
       } catch (InvalidPassWordExcepton e) {
          // you are hanlding invalid login
           tryAgain();
       }
      }

  7. #7
    @kamsky: Well done. General practice can be considered as part of the study. My study is a comparative of the said programming languages in terms to exception. It is correct as you have cited a few in C, C++, Java and .NET with regards to the checked and unchecked exceptions.

    Though I have some experience but considered myself is in need of more inputs from other programmer. I am taking this opportunity with Istorya.net to query some thoughts in exception handling from other experienced programmer to support my research as a resource, yes their practices, differentiate available exceptions in the programming languages, choosing the best and etc. There are journals, articles and other resources available in the web but it is best if we have it locally like this

    Thank you.

  8. #8
    C.I.A. Sarevok's Avatar
    Join Date
    Apr 2007
    Gender
    Male
    Posts
    2,802
    Blog Entries
    4
    hmmm I don't like cactching exceptions. I just flag an error and exit/crash the app. Easier to debug this way. But that's just me

  9. #9
    Junior Member
    Join Date
    Jun 2009
    Gender
    Male
    Posts
    478
    Quote Originally Posted by Sarevok View Post
    hmmm I don't like cactching exceptions. I just flag an error and exit/crash the app. Easier to debug this way. But that's just me
    That belongs to unchecked exception. It is a good practice.

  10.    Advertisement

Similar Threads

 

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top