The "One-Way" Mapping Strategy
There is yet another mapping strategy with another set of pros and cons – the "one-way" strategy sketched in the following figure:
Figure 8.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 for 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 map it into their own model...