[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ilug
Subject:    [ILUG] An OT Java question..
From:       Braun Brelin <bbrelin () gmail ! com>
Date:       2011-04-06 18:43:38
Message-ID: BANLkTimBNc5z1-QA4PnbHtc8okBNVS27_Q () mail ! gmail ! com
[Download RAW message or body]

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
-- 
Irish Linux Users' Group mailing list
About this list : http://mail.linux.ie/mailman/listinfo/ilug
Who we are : http://www.linux.ie/
Where we are : http://www.linux.ie/map/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic