Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A standard approach, and one I take often, is to have a common library of object models representing my domain: Customer, Order, OrderLine, etc, that are shared across all layers. </p> <p>Better still, don't share the types across layers, just share the interfaces and have a factory available when instances are required.</p> <p>You can then have a pluggable DAL, but your DAL still needs to conform to the contract of returning an ICustomer.</p> <p>This doesn't stop references from being required, a reference to at least the interfaces are needed - as someone else has commented, other references, for the strong types or factories, could then be factored out - such as with IoC/DI frameworks.</p> <p>The way I see it: a commom model is a cross-cutting concern in your application design, and shouldn't be seen as breaking the layering.</p> <p><strong>Update:</strong> this is a very vague explanation of the solution, so I stand to have it built upon.</p> <p><strong>Update 2:</strong> and now of course to answer your question. A standard way to remove a reference to a DLL directly is to expose the contract via an interface, in your case a DAL method <code>GetCustomers</code>, your Service Layer talks to the interface, but requests a DAL instance via a Dependency Injection / Inversion of Control framework, or more easily, a factory. I usually go the factory route for small apps, it involves another DLL. Service Layer will reference interfaces and factory, DAL will reference interface, factory will reference interface and DAL.</p> <p><img src="https://i.stack.imgur.com/pI9WQ.png" alt="enter image description here"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload