LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] An OT Java question..

[ILUG] An OT Java question..

Braun Brelin bbrelin at gmail.com
Wed Apr 6 19:43:38 IST 2011


Hello all,

I have a quick question regarding Java.

If I have a class foo  that takes, in its constructor a string "date" which
is supposed to be an dd/nn/yyyy string,
where is the best place to handle an exception if the supplied "date" string
isn't in the proper format.

For instance, if I have the constructor convert the date into a DateFormat
object, and knowing that the DateFormat
object throws a ParseException if the string isn't in that format, is there
a particular "convention" as to where and
what the exception should do?  I.e. Assuming that I catch the exception in
the constructor, is it considered a
better solution to complain and quit in the constructor method?  Is there a
better option?  Also, in a more general sense,
is it considered proper or not to quit if any class method catches an
exception or is it better to return some value like null
to warn the calling class that the method failed?

Thanks,

Braun


More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell