i'm wondering if it is preferred practice to throw exception in this
circumstance. I have seen it done like that, but i have also read that you
should try to never throw an exception in circumstances where you can do
some test before the operation that would throw the test so that you can by
pass the exception handling which is an expensive operation.
So lets say the scenario is i have an object that is validating itself in
the business layer. When a property doesn't pass validation, i want the UI
to be able to display the failure reason, so the error message that the
business layer sets has to propogate to the UI.
I have seen it done where the object throws exception with special message
which is then caught in UI and displayed to user that way.
Another way i've seen it is the business object simply sets the operation to
return false meaning the validation failed, and it sets a member variable
with the error message so that it can then be accessed in the UI to display
the error message that way.
Any comments on the best practice for doing this?
thanks a bunch