Re: Throw Exceptions from setters: second opinion
- From: Hugh Oxford <arestes@xxxxxxx>
- Date: Tue, 30 Dec 2008 14:06:44 +0000
amygdala wrote:
Furthermore he stated that throwing Exceptions is only meaningful when an internal routine of the class encounters invalid data.
Exactly. And if you're trying to set something that should not be null or empty, throw an exception.
If setting it is optional, delegate the decision to setting it to higher up in the order of events.
The sooner you catch problems the better. A setter a good place to do it.
.
- References:
- Throw Exceptions from setters: second opinion
- From: amygdala
- Throw Exceptions from setters: second opinion
- Prev by Date: Re: Query String
- Next by Date: Re: Throw Exceptions from setters: second opinion
- Previous by thread: Re: Throw Exceptions from setters: second opinion
- Next by thread: public library script
- Index(es):