Contents
Should domain objects throw exceptions?
If it is a Domain Exception, it means that it is thrown by the domain. Anyway, exceptions thrown by the domain should be handled by the application layer.
How do you handle exceptions in DAO layer?
its a good idea to create your own independant exceptions for each layer. For example, if you are using a particular DAO implementation, you should wrap the implementation specific exception to your own generic exception and throw it forward to Service Layer.
What is a DAO exception?
The Data Access Object (DAO) support in Spring allows us to isolate minimal amount of code related to particular database technology easily. This allows one to switch between the persistence technologies easily without changing a lot of code. Also DataAccessException is a RuntimeException exception.
How are validation rules thought of in DDD?
In DDD, validation rules can be thought as invariants. The main responsibility of an aggregate is to enforce invariants across state changes for all the entities within that aggregate. Domain entities should always be valid entities.
What is validity in domain driven design ( DDD )?
Validity may be a trivial statement such as “The string representing a customer’s name must not be null” or it may be a complex sequence of CycLassertions. This post addresses validation as manifest in DDD-based enterprise applications.
Why is validation difficult to implement in practice?
Validation is difficult to implement in practice because it must be implemented throughout all areas of an application, typically employing different methods for each area. In a general sense, validation is a mechanism for ensuring operations result in a valid states.
How to deal with validation errors in domain model?
You can do this by returning a result object instead of exceptions in order to make it easier to deal with the validation errors. Using field validation with data annotations, for example, you do not duplicate the validation definition.