-
Book Overview & Buying
-
Table Of Contents
Get Your Hands Dirty on Clean Architecture
By :
One question that comes to mind when implementing services is how to slice the port interfaces that define the database operations available to the application core.
It's common practice to create a single repository interface that provides all database operations for a certain entity, as shown in the following figure:
Each service that relies on database operations will then have a dependency on this single "broad" port interface, even if it uses only a single method from the interface. This means we have unnecessary dependencies in our codebase.
Dependencies on methods that we don't need in our context make the code harder to understand and to test. Imagine we are writing a unit test for RegisterAccountService from the preceding figure. Which of the methods of the AccountRepository interface...
Change the font size
Change margin width
Change background colour