Code smell – too many dependencies
Using this kind of mapping could become tedious in the long run, and we would rapidly see scenarios such as injecting three or more mappers into a single request delegate or controller. The consumer would likely already have other dependencies, leading to four or more injected dependencies.
That should raise the following question:
- Does the class do too much and have too many responsibilities?
In this case, the fine-grained IMapper
interface pollutes our request delegates with tons of dependencies on mappers, which suggests that the class may be doing more than it should, likely violating the Single Responsibility Principle by carrying an excessive number of responsibilities. This can lead to several downsides, such as:
- Reduced readability: A class with too many dependencies becomes complex and harder to understand
- Decreased maintainability: Changes in one part of the code may have unexpected effects...