Slicing Port Interfaces
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:
Figure 6.2: Centralizing all database operations into a single outgoing port interface makes all services depend on methods they don't need
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...