title: Clarification on Port and Adapters / Hexagonal architecture
body: <p>I have read Alistair's <a href="https://alistair.cockburn.us/hexagonal-architecture/" rel="nofollow noreferrer">article</a> on Hexagonal pattern and gone through other resources related to this (<a href="https://www.youtube.com/playlist?list=PLGl1Jc8ErU1w27y8-7Gdcloy1tHO7NriL" rel="nofollow noreferrer">Alistair's videos</a>, <a href="http://www.dossier-andreas.net/software_architecture/ports_and_adapters.html" rel="nofollow noreferrer">Short description of Ports &amp; Adapters</a>).</p>
  <p>I understand the general idea of Hexagonal architecture and what are the advantages it brings to modern application development. But still, I have some confusion related to the actual implementation of Ports and Adapters.</p>
  <p><strong>Question 1:</strong></p>
  <p>From Alistair's article,</p>
  <p><a href="https://i.stack.imgur.com/2IZJi.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2IZJi.gif" alt="enter image description here" /></a></p>
  <blockquote>
  <p>In an implementation, ports and adapters show up in two flavours,
  which I’ll call <strong>primary</strong> and <strong>secondary</strong>, for soon-to-be-obvious reasons.
  They could be also called <strong>driving</strong> adapters and <strong>driven</strong> adapters.</p>
  </blockquote>
  <p>He Separates ports into two categories which are driving ports and driven ports. Driving ports control the application (GUI) and Driven port controlled by the application (database).</p>
  <p>So if the driving port should only contain control APIs then how the Adapters at driving port side will get the event notifications. For example, in the below diagram I have two driving adapters which control the application but it also needs information from the application to send it back to other application connected to that adapter.</p>
  <p><a href="https://i.stack.imgur.com/b9aQY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/b9aQY.png" alt="enter image description here" /></a></p>
  <pre><code>Interface IDriving {
  
  //control application
  startService();
  stopService();
  
  //Events send from application
  statusInfoEvent();
  }
  </code></pre>
  <p>You could consider the <code>statusInfoEvent()</code> as a Qt signal emitted from the application side or some common observable pattern.
  <strong>Is it a violation of Hexagonal pattern to keep the incoming and outgoing traffic API at the same Interface (port) ?</strong> and most importantly the implementation is done inside the hexagon as it's a driving port.</p>
  <p><strong>Question 2:</strong></p>
  <p>Have ever seen or worked on Hexagonal pattern like below.
  <a href="https://i.stack.imgur.com/h0vEL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/h0vEL.png" alt="enter image description here" /></a></p>
  <p>Consider the driven adapter of service 1 as some storage medium, service 1 can push and pull information to/from it. These two adapters of service 1 (both driving and driven) is implemented inside service 2 (at least in project level), Now service 2 receive some data from it's driving adapter (web or dbus) and update the storage medium of service 1 driven adapter, also it needs to notify the updation to service 1 through the driving adapter.</p>
  <p>Is it possible to do this in a better way?</p>