Jump to content
  • Advertisement
Sign in to follow this  
Guest m41q

Question on Exceptions

This topic is 2482 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Guest m41q
Hi,

I nearly never used Exceptions in my Programs until now (well, it worked fine until nowwink.png ),
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

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!