DDD – Does DDD + POCO Make Sense

asp.net-mvcdomain-driven-design

DDD promotes rich domain models with behavior in it, POCO naked objects without any objects in it. Is it possible to have them both combined?

I have a Multi Layer Solution

  • Core – has POCO Entieties, interfaces for Repositories and Services
  • Data – Repository implementations
  • Service – Service Implementations
  • Infra – IoC Locator/registrar, viewmodels, (could be merged to webui)
  • WebUI – asp.net mvc presentation layer

I was saying that I use DDD but recently I've been told that I'm not because my Entities don't have behavior, is this true?

Best Answer

POCO stands for plain old c# objects. It comes from the java equivalent POJO. It's just a hip name to show the world that not everything has to be a derived class. POCOs are not necessarily DTOs, they can be full blown objects with behavior and state and clild POCOs, while DTOs only have state.

Now about your domain - if as you say you are trying to do DDD but your entities don't have behavior than you've been bitten by the anemic domain model anti-pattern. Grab Mr. Evans book on Domain Driven Design and after reading it start planing your model refactoring, preferably with your domain expert.

Also worth mentioning that the anemic domain model is not by itself an anti-pattern, only when you try to do DDD and end up with and anemic model. So if your apps are doing fine and your users are happy, don't bother refactoring for the sake of DDD, just keep it in mind for the future.

This link might help you identify other problems