Tutorial :ASP.NET MVC with DDD architecture



Question:

I am trying to understand Asp.Net MVC with DDD following is the structure of application according to the http://aspnetdesignpatterns.codeplex.com/

Application Layers

Presentation Layer => MVC views,

Controllers(MVC) => MVC Controllers class,

Cached Service => ?,

Application Service => ?,

Domain Model => ?,

Repository => repository class to interact with DB,

Infrastructure => Class for logging, mailing etc.

here m having confusion in Application service and domain model, where should i fit my business logic (in service or in domain model)

what exactly should be in service and what should be in domain.

e.g suppose i want to add customer in DB how should be the flow..?

as i know,

in controller class i will write like

var customeService = new CustomeService (_customerRepository);  customeService.Add(customer);  

if m wrong please correct me here..

_customerRepository goes in repository

what goes in model and what should be the flow of code.

please clear me. thanks in advance.


Solution:1

Have You read this book? Start with that.

Term Service is overloaded.

Domain services encapsulates small part of domain logic that does not fit naturally in any of domain object (some say it's a sign that there's unidentified aggregate root in Your domain).

Application services contains zero domain logic. They coordinate domain.

Infrastructure services seems to me quite self-explanatory. Those contain technical details.


Solution:2

Eric Evan's book is the best place to start DDD as mentioned by @Arnis. Domain Driven Design Quickly is a short, quick-readable summary and introduction to the fundamentals of DDD.

what goes in model and what should be the flow of code.  

Please check the following answer from @calebboyd to get an idea of DDD flows.

And about MVC, you can separate the controller from your presentation layers(views). But are you using this controller actions in different projects? If answer is no, my opinion is to keep it in one project.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »