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 a common practice to create a single repository interface that provides all database operations for a certain entity, as outlined in Figure 7.2.
Figure 7.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 code base.
Dependencies on methods that we don’t need in our context make the code harder to understand and test. Imagine that we’re writing a unit test for RegisterAccountService from the preceding figure....