After reading different sources about the Ports & Adapters architecture including Alistair Cockburn's original article I am still not sure about the definite meaning of the terms "port" and "adapter" - especially when it comes to mapping these concepts to implementation artifacts.
Several sources (e. g. this post) imply that the ports in this architecture pattern are artifacts at the very outside, followed by the adapters in the intermediate layer that translate between the ports and the application that is at the heart.
However, in Cockburn's original article the ports appear at the outside as well as on the inside of the adapter layer dependent on the direction of communication:
- Inbound communication: "As events arrive from the outside world at a port, a technology-specific adapter converts it into a usable procedure call or message and passes it to the application."
- Outbound communication: "When the application has something to send out, it sends it out through a port to an adapter, which creates the appropriate signals needed by the receiving technology (human or automated)."
Actually for me neither the "all outside" approach nor the "inside and outside" approach make sense - I would see the ports as artifacts that are always placed next to the application regardless of the direction of communication. Imo this would also be consistent with the port and adapter metaphors: E. g. having a device with a serial port, to connect another device without a serial port to this I'd need an adapter that adapts inbound and outbound communication from the viewpoint of my device.
Coming to the implementation of this architecture I'd see the definition of the ports rather as a part of my application where I'd see the different adapters as being "outside" of my application. E. g. an implementation of a single port could consist of a facade
(to be called by adapters for inbound communication) and an interface
(to be implemented by adapters for outbound communication).
What is the correct meaning of the terms port and adapter and how can these concepts be mapped to implementation artifacts?
UPDATE:
Found this article which resembles my understanding. The question remains if there is some kind of common agreement.