A role interface defines an output port around what the application core needs from an external collaborator. Unlike a header interface, it does not mirror the implementing class’s API or expose delivery-specific vocabulary. section 5.2.2
Design the port from the inside out:
- Express the core’s need in application vocabulary, not terms tied to a delivery technology. section 5.2.2
- If parameters make sense only for one implementation, redesign the interface; implement the core-owned port in an outer adapter. section 5.2.2 section 5.5
Notification port
A role interface can expose notify(NotificationTextDTO, NotificationTypeDTO) rather than send(subject, body, recipients, cc, bcc). The adapter decides how to deliver the notification. 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.
Compare an implementation-shaped header interface with a consumer-shaped role interface. section 5.2.2
