Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your repositories should really be implemented in your Persistence assembly. Assuming you are unit testing them, you would define the interface for each repository in your Domain assembly.</p> <p>Your <code>CreateUser</code> method shouldn't be directly querying the database to determine if the email address already exists, instead create a separate method in your <code>DoesEmailExist</code> which is responsible for doing that check. Each method should have a single responsiblity.</p> <p><strong>In response to jfar's doubts:</strong> </p> <p>That's right, the domain defines what can be done, defining interfaces such as <code>Domain.IUserRepository.Create(User user)</code>. The domain does not however define any implementation.</p> <p>Let's say you start out using Entity Framework, you might create a <code>Persistence</code> assembly which implements the interfaces defined in the domain. So following on from the domain interface above we implement the interface:</p> <pre><code>namespace Persistence { public class UserRepository : Domain.IUserRepository { public void Create(User user) { // use Entity Framework to persist a user } } } </code></pre> <p>Let's say for example that your customer later tells you to implement an NHibernate persistence layer. Luckily our domain is separate to the existing persistence layer - it's in the domain. So you can easily implement the existing domain interfaces without needing to change any code in your MVC application - as all that knows about is the interface you defined, not the Entity Framework implementation.</p> <p>Your IoC container can then be configured to resolve <code>IUserRepository</code> as either the Entity Framework or NHibernate implementation, your MVC application doesn't care either way.</p> <p>In terms of assembly references, the <code>Persistence</code> assembly has a reference to the <code>Domain</code>, and the <code>Domain</code> quite rightly does not have a reference to <code>Persistence</code>.</p> <p>This leads to a <em>decoupled</em> design which is easy to test, and change going forwards, resulting in easier maintenance.</p> <p>I hope that helped.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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