I am applying the principles of Hexagonal Architecture (Ports and Adapters) and one aspect is slightly bothering me. In my opinion, the ports and adapters of the secondary actors should completely be isolated from each other. No dependencies between them. Maybe this is a false expectation but it instinctively feels right to me.
I am having a hard time enforcing this separation. A very simple example is the following use case (don't worry about the details):
Loggingsecondary port that is responsible for creating/handling the logs of the application. The adapters are not that important but let's just assume that there is
StandardOutputLoggingadapter for now; it just sends the logs to standard output.
There is also another port named
EmailSendingwhich is responsible for sending e-mails. Again, the adapters don't matter too much.
The issue happens when I want to log what happens in the e-mail sending functionality. The
EmailSendingadapters need a handle on the
Loggingport. This does create a dependency between the two secondary ports of the application.
It is also an issue during the wiring of the system as well.
Loggingadapter should be created first and then passed to the
EmailSendingadapter. That also creates an implicit dependency.
How do we solve this?