In a Spring application, my point of view is that each domain model which in fact is a POJO, should encapsulate all the validation logic in itself. Now whenever there is an update or insertion, they should throw proper exceptions that are modeled after the business process like CustomerNotFound
AlreadySold
, CannotAllowReturnOfExpiredItem
and like.
These exceptions are not caught at the DAO or Service layer rather in controllers and each exception has a message key that is displayed on the view after getting it through the Application.Resources.
My question is that Exceptions being used in this way, is this appropriate? Some are of the view that exceptions are only for the debugging purposes and they'd let you know what's wrong and where so throwing exceptions from the business logic is not a good thing.
What would you add to this?