Note that there are some explanatory texts on larger screens.

plurals
  1. POServices and Repositories in DDD (C#)
    primarykey
    data
    text
    <p>How do <code>Services</code> and <code>Repositories</code> relate to each other in DDD? I mean, I've been reading up on DDD for the past 2 days and everywhere I go, there's always a <code>Service</code> layer and there's always a <code>Repository</code> layer. How do these differentiate or compliment each other?</p> <p>From what I've read, isn't the <code>Repository</code> the layer responsible for delegating interactions between the application and the data?</p> <p>So, what's the need for the <code>Service</code> layer if it has to implement the <code>Repository</code> to interact with the data anyway even though the <code>Repository</code> probably already implements the methods needed to do so?</p> <p>I'd appreciate some enlightenment on the subject.</p> <p>P.S. Don't know if this will help any, but I'm working with an ASP.NET MVC 2 application in which I'm trying to implement the Repository pattern. I just finished implementing the Dependency Injection pattern (for the first time ever)...</p> <p><strong>UPDATE</strong></p> <p>Okay, with so many answers, I think I understand what the difference is. So, to review (correct me if I'm wrong):</p> <ul> <li><p>A <code>Repository</code> layer interacts only with a single object out of the database or the ORM, <code>IEmployeeRepository</code> -> <code>Employee</code>.</p></li> <li><p>A <code>Service</code> layer encapsulates more complex functionality on objects returned from <code>Repositories</code>, either one or multiple.</p></li> </ul> <p>So, then I have a sub question. Is it considered bad practice to create abstract objects to be sent to my views? For example an <code>AEmployee</code> (<code>A</code> for <code>abstract</code> because to me <code>I</code> means <code>interface</code>) which contains properties from <code>Employee</code> and <code>X</code> or <code>X</code>?</p> <p>Actually, one more subquestion. If a <code>Service</code> layer can be considered "tuned" for an application does it need to be implemented with an interface?</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.
 

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