开发者

Is clean domain-driven-design(DDD) a utopia? [closed]

开发者 https://www.devze.com 2023-03-11 22:58 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

I think I read all the book's on DDD and how to apply it in C# (3-5 books, don't remember it was few years ago).

But during last 2 years I was using anemic domain model in all projects and it worked well. Actually I have never tried to implement pure domain model, moreover I have never seen a piece of code using clean domain model approach.

Take for example code from the book's about DDD doesn't follow DDD style. Take for example code code 开发者_StackOverflow社区from Tim MacCarthy book about DDD http://dddpds.codeplex.com/, look at his domain objects, they are clean from any behavior's it's just DTO's the only thing he integrated into domain object is validation, if I remember correctly in DDD your domain should not be in invalid state, so you should prevent setting invalid values and throw exception's instead of allowing to set them and do validation at some point.

Same situation with other books and sample codes, they all are very simple and shows just a class with properties, maximum what you can find is a set of methods for inserting\removing child objects which set the parent property. For example I almost neven seen code using domain events, or injecting services into domain objects.

In 2003 Martin Fowler wrote an article telling us that Anemic Domain Model is a bad thing http://www.martinfowler.com/bliki/AnemicDomainModel.html 8 years passed and I think Anemic model is quite popular now (it evoluted to Layered Architecture). And is used alot in 3-Tier RIA development.

So my main question is clean DDD a utopia? Is it dead? Becouse all the code I see around for last 3 years is Layered Architecture (in my opinion it's essetialy anemic domain model). And I would very like to see some clean DDD code if it exists.


You are not alone. In most places true DDD will be an utopia. In my experience it is due to two main reasons.

  1. The business is not mature to help developers to do the domain modelling. There is not enough time, resource, energy to do it.
  2. The project team is not very experienced specially if they haven't done DDD before.

DDD is also not suitable in many CRUDy apps. There is also alternate approaches like CQRS. see also the following blog links that make a case for anaemic domain models.

http://codebetter.com/gregyoung/2009/07/15/the-anemic-domain-model-pattern/
http://lostechies.com/jimmybogard/2009/12/03/persistence-model-and-domain-anemia/

0

精彩评论

暂无评论...
验证码 换一张
取 消