The “One-Way” mapping strategy
There is yet another mapping strategy with another set of pros and cons: the “One-Way” strategy visualized in Figure 9.4.
Figure 9.4 – With the domain model and the adapter models implementing the same “state” interface, each layer only needs to map objects it receives from other layers one way
In this strategy, the models in all layers implement the same interface, which encapsulates the state of the domain model by providing getter methods on the relevant attributes.
The domain model itself can implement a rich behavior, which we can access from our services within the application layer. If we want to pass a domain object to the outer layers, we can do so without mapping since the domain object implements the state interface expected by the incoming and outgoing ports.
The outer layers can then decide whether they can work with the interface or whether they need to...