title: In an Onion type architecture, should the entities cross the outer layer?
body: <p>I've been trying to understand this new kind of architecture which names can be Onion architecture, Clean architecture, Ports and Adapters, etc.</p>
  
  <p>If I take the abstraction of Ports and Adapters, when I adapt my application for a particular port, is it ok for me to give the port an entity from inside my application? Or am I always supposed to adapt the entities also, to fit the port?</p>
  
  <p>Example:</p>
  
  <p>Say I have a Customer entity. I have a UI that uses my application. My UI calls through an Adapter to getCustomerById(123). In turn, my adapter will call through to my application, effectively retrieving a Customer using the injected Repository, and it will perform some sort of formatting on it and logging and what not, once the Customer is ready, it is returned to my UI. My question here is, my Customer object is returned as is to my UI. This means my UI has a reference to the Customer class from my Core project. My UI then goes on using that Customer object to do things, maybe change it's name, etc. and eventually calls the adapter again to updateCustomer(customer).</p>
  
  <p>Is this ok to do? Is it ok that my UI uses the Customer class from inside my application core. Or should I instead adapt my Customer to a new Customer object say UICustomer and have my UI work with that instead, mapping back and forth between Customer and UICustomer at the adapter level?</p>