👨‍💻
Software Engineering
Implementing Domain Driven Design
Implementing Domain Driven Design
  • Intro
  • 1. Getting Started with DDD
    • The Business Value of DDD
  • 4: Architecture
  • 5: Entities
    • Why We Use Entities
    • Unique Identity
  • 6: Value Objects
    • Value Object Characteristics
    • Integrate with Minimalism
    • Standard Types Expressed as Values
    • Resources
  • 10: Aggregates
  • 8: Domain Events
    • The When & Why of Domain Events
    • Modeling Events
    • Publishing Events from the Domain Model
  • 13: Factories
  • Resources
Powered by GitBook
On this page
  • Chapter Roadmap
  • Factories in the Domain Model

13: Factories

Chapter Roadmap

  • Learn why the use of Factories can produce expressive models that adhere to Ubiquitous Language

  • See how factory methods can be used as Aggregate Behaviors

  • Consider how to use Factory Methods to create Aggregate instances of their types

  • Learn how Domain Services can be designed as Factories while interacting with other Bounded Contexts and translating foreign objects to local types.


Factories in the Domain Model

  • Shift the responsibility of creating instances of complex objects and Aggregates to a separate object.

  • Even if these objects have no responsibility in the domain model, they are still part of the domain model.

  • Factories provide an interface that encapsulates complex assembly without requiring the client to reference concrete classes of objects instantiated.

  • Factories can create an entire Aggregates as a piece while enforcing their invariants.

  • An aggregate root that provides a Factory for another Aggregate type will have the primary responsibility of providing main aggregate behavior, the Factory being just one of those.

  • Factory Methods on aggregates allow you to express the Ubiquitous Language in way not possible through constructors.

  • When the behavioral name is expressive with respect to the Ubiquitous Language, we have a powerful case for using a Factory Method.

PreviousPublishing Events from the Domain ModelNextResources

Last updated 28 days ago