The "Two-Way" Mapping Strategy
A mapping strategy where each layer has its own model is what I call the "two-way" mapping strategy, outlined in the following figure:
Figure 8.2: With each adapter having its own model, the adapters are responsible for mapping their model into the domain model and back
Each layer has its own model, which may have a structure that is completely different from the domain model.
The web layer maps the web model into the domain model that is expected by the incoming ports. It also maps domain objects returned by the incoming ports back into the web model.
The persistence layer is responsible for a similar mapping between the domain model, which is used by the outgoing ports, and the persistence model.
Both layers map in two directions, hence the name "two-way" mapping.
With each layer having its own model, each layer can modify its own model without affecting the other layers (as long as the contents are unchanged). The web...