Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think there are a few things you can do that together could help with your design. I also think that you might want to read up on <a href="http://en.wikipedia.org/wiki/Dependency_injection" rel="nofollow noreferrer">Dependency Injection</a> as perhaps providing a better design pattern for what you want to do.</p> <p>Assuming you just want to make what you have work though:</p> <ul> <li><p>First, remove the <code>static</code> methods from your <code>User</code> class, since they 'create' users, and therefore are best just left on the <code>UserMapper</code>.</p></li> <li><p>After that, there will still be a number of methods potentially that use <code>UserMapper</code> functionality from the <code>User</code> class. Create an interface <code>IUserLookup</code> (or something) that supports the <code>UserNameExists</code> and <code>UserNamePasswordExists</code> methods; put this interface in the same project as the <code>User</code> class.</p></li> <li><p>Implement the <code>IUserLookup</code> on the <code>UserMapper</code> class, and then 'inject' it into the <code>User</code> class instances it creates with the static methods through a constructor, so basically, as the <code>UserMapper</code> creates <code>User</code> objects, it gives them a reference to the <code>IUserLookup</code> interface that it implements itself.</p></li> </ul> <p>In this way, <code>User</code> only uses methods on <code>IUserLookup</code>, which is in the same solution, so no reference needed. And <code>UserMapper</code> references this solution, so it can create <code>User</code> objects and implement the <code>IUserLookup</code> interface.</p>
    singulars
    1. This table or related slice is empty.
    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