Re: Throw Exceptions from setters: second opinion



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.
.