Factories
Explore how factories serve as a tactical pattern in Domain Driven Design to create complex objects. Understand when to use factories to separate business logic from object instantiation and how they simplify managing aggregates and external dependencies.
We'll cover the following...
As Eric Evans mentions in his book, there may be occasions when an object’s creation and assembly are complex. Such a process may need to orchestrate a lot of logic to create the complex object. With regards to this, he mentions an example related to the opening of a bank account. This process requires many objects in order to be executed properly. Oftentimes, the logic required to create those objects is not related to business logic, which can mess up the business logic. Refering to the Eric Evan’s example, let us imagine ...