2

DDD Newbie question:

I read in a blog somewhere that in a scenario where objects are closely associated with each other in a domain driven design, and where one object based on some complicated business rule is responsible for the creation of a dependent object, in such a design the usefulness of dependency injection is very limited.

Would you agree?

1 Answer 1

1

No, I wouldn't agree.

The whole purpose of DDD is to arrive at an expressive model that facilitates change. It is accepted as a given that business logic often changes, so the model must be flexible enough to enable a quick change of direction in the face of changing requirements or new insight.

As Uncle Bob writes in Clean Code, the only way to enable a flexible and expressive API that can quickly address unprecedented change is to use loose coupling. Loose coupling is achieved through the Dependency Inversion Principle; from there, the connection to DI follows naturally.

As I read Domain-Driven Design, this was always the underlying motivation behind all the talk about Factories, but I personally find the book a little vague there.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.