DEV Community

Discussion on: Layered Architecture Clarification

Collapse
 
lazypro profile image
ChunTing Wu

For a simple application, it is feasible to use ORM instead of Repository. However, in an enterprise application, the domain object is not one-to-one mapping to a table or some rows. A domain object is composed of many data, and there are rich constraints between the data. This is also called Impedance Mismatch.

In order to solve the mismatch, we usually introduce a Repository between the domain layer and storage layer. Repository is not only responsible for accessing the data but also ensure the data constraints.