Question

I am using Dozer to map my domain objects to resource objects (REST) which only contains the data. I am currently doing this mapping in my web layer. However should I move the translation to the service layer?

Was it helpful?

Solution

I don't know your architecture, but I guess that you have layers in a hierarchical order and access should only be allowed from a higher layer to a lower, right?!

Based on that assumption...

If you move the mapping to the service layer, the service layer will be aware of the REST API. Thus you introduce a dependency from a lower layer (service) to a higher layer (presentation). I guess this does not comply to your architecture, because a service layer's purpose is normally to provide a presentation free API to access domain logic. Thus I would not move the mapping to the service layer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top