title: how to separate the use cases from the view in software development?
body: <p>I have a hard time understanding how to actually implement the clean architecture,</p>
  <p>taking note of the following point regarding the clean architecture.</p>
  <p><a href="https://i.stack.imgur.com/YyOqQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YyOqQ.png" alt="enter image description here" /></a></p>
  <ul>
  <li>the inner circle should not know about the outer circle</li>
  <li>the use case should not know about the web/framework</li>
  <li>the use case should not know about view</li>
  </ul>
  <p>traditionally while developing any react or any other application. the main focus is on the &quot;VIEW&quot;
  so, the view defines the use case and the use case defines the entity.
  thence the end result was that the use case is tightly coupled with the view.</p>
  <p>so the control starts from the view when the user interacts with the UI, and the view calls the use case and uses case uses the entity and returns the result to the view.</p>
  <p>with this, it's hard to see the use case and views as separate.</p>
  <p>how do we achieve the separation of the view from the use case?
  and flow of control from the controller to the use case to the and then to view.</p>
  <p><strong>The Problem</strong></p>
  <p>from the above diagram, it's clear that the controller calls the uncase interactor via the input port interface. and the use case updated the UI with the Outport port.</p>
  <p>so, let's say we have the entity as follows.</p>
  <pre><code>{ x : &quot;data x&quot;, y : &quot;data y&quot;, z : &quot;data z&quot;}
  </code></pre>
  <p>the output will be displayed either in the CLI or WEB.</p>
  <p>and suppose there is some use case operation <code>op()</code>
  after performing the <code>op()</code> the result will be displayed to the user.</p>
  <p>but, if the UI is WEB then the data <code>x</code> and <code>y</code> should be displayed.</p>
  <p>and if the UI is CLI then the data and <code>z</code> should be displayed.</p>
  <p>how do we distribute the logic to achieve clean architecture?.</p>
  <p>one solution could be, we can have the output port interface like.</p>
  <pre><code>interface Presenter
  {
     public void presentForWeb({ x : &quot;data x&quot;, y : &quot;data y&quot; });
     public void presentForCli({ z : &quot;data z&quot; });
  }
  </code></pre>
  <p>but this violet the architecture. since the Use case, they should know about the UI to be able to properly display the data.</p>
  <p>Another solution would be, to have the output port as</p>
  <pre><code>interface Presenter
  {
     public void present({ x : &quot;data x&quot;, y : &quot;data y&quot;, z : &quot;data z&quot;  });
  }
  </code></pre>
  <p>this is almost a good solution, but there we are passing some redundant data. so what if the z data is large we only need to pass it when using the CLI.</p>
  <p>is there a better solution, to achieve the clean architecture?</p>