Ports and Adapters
Ports and Adapters addresses the problem of keeping domain and application semantics independent from specific infrastructure, protocols, user interfaces, and external systems.
Cohesive Formulation
Ports are named attachment roles through which a component provides or requires an interface at a boundary. Endpoints are the bound loci through which those port roles participate in particular channel arrangements. Adapters are realization mechanisms that translate among interface roles, component behavior, messages, and substrate mechanisms without making the port, endpoint, interface, boundary, channel, or binding synonymous.
The practice asks:
- Which boundary is being crossed?
- Which provided or required interface does the port represent?
- What semantic object enters or leaves the boundary?
- Which observer interprets the input?
- Which interaction protocol governs the conversation?
- Which endpoint and channel directions are attached by the interaction binding?
- What channel realization, protocol binding, storage mechanism, UI, or external system realizes the edge?
In the Model
An inbound adapter admits an external occurrence as an input event relative to an observer and supplies the carried value and contract for interpretation as a command, query, event notification, signal, or other role. An outbound adapter realizes an endogenous event, request, signal, reply, query, command intent, or observation as a protocol-specific effect. The adapter preserves a correspondence; it does not collapse transport classification into semantic interpretation.
Enterprise Integration Patterns channel adapters, messaging gateways, messaging mappers, and service activators are specialized endpoint and adapter structures. They should remain outside the semantic authority that decides domain transitions.
Failure Modes
The pattern fails when adapters leak substrate semantics into the domain, when ports are treated as concrete network endpoints, when endpoint addresses become semantic identity, or when interfaces are described without stating their semantic boundary, protocol, binding, and authority.
Formal relations
corresponds_to: Clean Architecture — Shares a dependency-direction and boundary-separation structure while retaining distinct interface-role and layering vocabularies.
External References
- Gregor Hohpe and Bobby Woolf, Channel Adapter, Messaging Gateway, and Messaging Mapper, Enterprise Integration Patterns, 2003.
Related concepts: enterprise integration patterns, boundaries, interfaces, interaction protocols, interaction bindings, endpoints, observer, observer models, command, query, observation, event, messages and envelopes, interaction, interaction channels, compatibility and evolution, network channels, network, application hosts, realization, anti-corruption layer.