How does this help me build maintainable software?
Our architecture lets us implement the domain logic as we see fit, but if we model the input and output of our use cases independently, we avoid unwanted side effects.
Yes, it’s more work than just sharing models between use cases. We have to introduce a separate model for each use case and map between this model and our entities.
But use case-specific models allow for a crisp understanding of a use case, making it easier to maintain in the long run. Also, they allow multiple developers to work on different use cases in parallel without stepping on each other’s toes.
Together with tight input validation, use case-specific input and output models go a long way toward a maintainable code base.
In the next chapter, we’re taking a step “outward” from the center of our application and will explore building a web adapter that provides a channel for users to talk to our use case.