Having all the mappers follow this interface gives you the advantage of
decoupling the mapping.
Can someone please explain who having an interface for mappers allows decoupling?
Having all the mappers follow this interface gives you the advantage of
decoupling the mapping.
Can someone please explain who having an interface for mappers allows decoupling?
In my opinion, you can look at this the same as the repository contract and the repository implementation. When creating an interface that’s used as the mapping contract we can pass it down to the repository implementation and not the mapper itself (Dependency inversion). This along with a dependency injection library such as Dagger/Hilt/Coin can make it very easy to maintain, change and scale the behavior of the related section in the app. Testing also will become easier since we’ll pass an interface rather than the class.