A header interface mirrors the implementing class’s public API: its shape comes from the implementation rather than the application core’s needs. Used as an output port, it can leak infrastructure vocabulary into the core. A role interface instead expresses what the core needs from an external collaborator. section 5.2.2
Check an output port for implementation-shaped language:
- Terms such as subject, body, recipients, cc, bcc, SMTP, or HTTP headers suggest the port mirrors a delivery technology. section 5.2.2
- Define the port from the inside: keep only what the core needs, and let the adapter choose how to deliver it. section 5.2.2
Notification port
A header-shaped port exposes send(subject, body, recipients, cc, bcc). A role-shaped alternative asks the adapter to notify(text, type), leaving delivery details outside the core. section 5.2.2
Figure 5.4 The header interface on the left is shaped by the email implementation. The role interface on the right is shaped by what the application core needs, keeping the port technology-agnostic.
The comparison shows how an implementation-shaped interface differs from a core-shaped role interface. section 5.2.2
