domain driven design - The placement of utility classes in DDD -


i'm trying figure out put utility classes in ddd based project. case follows:

i have class called cookieawarewebclient required core work. form i've read online seems class belongs in infrastructure tier, 1 not supposed refer infrastructure tier core tier. means cannot place functionality core tier depends on in infrastructure tier. should cookieawarewebclient class placed?

without understanding need do, believe @plalx sums in comments:

  • establish interface provides functionality core tier requires
  • implement interface in cookieawarewebclient
  • use dependency inversion allow core use cookieawarewebclient

here's code (c# in case) constructor injection example:

the interface:

namespace core {   public interface iblah   {     int somethingcoreneeds();   } } 

the implementation cookieawarewebclient:

namespace services {   public class cookieawarewebclient : iblah   {     // ... rest of class      private int _somethingcookieawarewebclienthasthatcoreneeds;      public int somethingcoreneeds()     {       return _somethingcookieawarewebclienthasthatcoreneeds;     }     // ... rest of class    } } 

the consuming service in core:

namespace core {   public class domainservice   {     private readonly iblah _blah;      public domainservice(iblah blah)     {       _blah = blah;     }      public void dosomething(domainentity entity)     {       entity.neededvalue = _blah.somethingcoreneeds();     }   } } 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -