title: Ports and adapters / hexagonal architecture - clarification of terms and implementation
body: <p>After reading different sources about the Ports &amp; Adapters architecture including Alistair Cockburn's <a href="https://web.archive.org/web/20180822100852/http://alistair.cockburn.us/Hexagonal+architecture" rel="noreferrer">original article</a> 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.</p>
  
  <p>Several sources (e. g. <a href="http://spin.atomicobject.com/2013/02/23/ports-adapters-software-architecture/" rel="noreferrer">this post</a>) imply that the <em>ports</em> in this architecture pattern are artifacts at the very outside, followed by the <em>adapters</em> in the intermediate layer that translate between the <em>ports</em> and the <em>application</em> that is at the heart.</p>
  
  <p>However, in Cockburn's original article the <em>ports</em> appear at the outside as well as on the inside of the <em>adapter</em> layer dependent on the direction of communication:</p>
  
  <ul>
  <li>Inbound communication: "<em>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.</em>"</li>
  <li>Outbound communication: "<em>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).</em>"</li>
  </ul>
  
  <p>Actually for me neither the "all outside" approach nor the "inside and outside" approach make sense - I would see the <em>ports</em> as artifacts that are always placed next to the application regardless of the direction of communication. Imo this would also be consistent with the <em>port</em> and <em>adapter</em> 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.</p>
  
  <p>Coming to the implementation of this architecture I'd see the definition of the <em>ports</em> rather as a part of my application where I'd see the different <em>adapters</em> as being "outside" of my application. E. g. an implementation of a single <em>port</em> could consist of a <code>facade</code> (to be called by adapters for inbound communication) and an <code>interface</code> (to be implemented by adapters for outbound communication).</p>
  
  <p>What is the correct meaning of the terms <em>port</em> and <em>adapter</em> and how can these concepts be mapped to implementation artifacts?</p>
  
  <p>UPDATE:</p>
  
  <p>Found <a href="http://www.dossier-andreas.net/software_architecture/ports_and_adapters.html" rel="noreferrer">this article</a> which resembles my understanding. The question remains if there is some kind of common agreement.</p>