Jump to content

  • Log In with Google      Sign In   
  • Create Account

Question on Exceptions


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 m41q   Members   -  Reputation: 151

Like
0Likes
Like

Posted 02 March 2012 - 12:12 PM

Hi,

I nearly never used Exceptions in my Programs until now (well, it worked fine until nowPosted Image ),
but I wonder, wether this may be (very?) bad coding style and wether I will get problems when my Project meets a certain size...

Basically my question is:
Are Exceptions in Java a "must-have" to simplify debugging and have clean code or are they just to have decent code (and are not that important)?

thx in advance

Sponsor:

#2 haegarr   Crossbones+   -  Reputation: 4313

Like
1Likes
Like

Posted 02 March 2012 - 12:49 PM

On the one hand they are important because each and every library throws exceptions, including the Java runtime library. So you have to deal with them. On the other hand there is a never ending discussion whether exceptions should be used as a general failure notification system or else just if programming errors are found. In the latter case you are required to check every eventuality before invoking a routine, while in the former case you rely on the checks being performed inside the routine. (Notice that there is also a small fraction that speaks of exceptions as a kind of more or less regular return mechanism, but that is widely seen as a serious misuse.)

That said, you can write programs that do not throw exceptions in own code, but you ever should handle exceptions possibly being thrown by 3rd party code. E.g. libraries that deal with files, networking, or similar stuff are ever good for throwing the one or other exception.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS