# Factory
> [!Note]
> A **Factory** encapsulates the **creation logic** for complex **domain objects**, providing a clear **interface** that ensures valid and consistent instantiation without exposing construction details.
A **Factory** centralizes the process of building [[Aggregate]], [[Entities]], or [[Value Objects]] whose creation involves intricate rules, dependencies, or invariants. By offering descriptive methods—such as `CreateOrderWithItems` or `NewAddressFromComponents`—it hides the internal steps required to assemble the object correctly, preventing clients from misconfiguring required properties. This approach promotes **separation of concerns**, keeping constructors simple or even private, while the **Factory** coordinates necessary collaborators, applies validation, and returns fully initialized instances ready for use in the domain. Factories thus maintain **model integrity**, reduce duplication of creation code, and make intent explicit in the ubiquitous language.
---
## References
- Vernon, V. (2016). _Domain-driven design distilled_. Addison-Wesley Professional.
- Vernon, V. (2013). _Implementing domain-driven design_. Addison-Wesley Professional.
- Khononov, V. (2021). _Learning domain-driven design: Aligning software architecture and business strategy_. O’Reilly Media.
- Alammar, J., & Grootendorst, M. (2024). _Hands-on large language models: Language understanding and generation_. O’Reilly Media.
- Evans, E. (2003). _Domain-driven design: Tackling complexity in the heart of software_. Addison-Wesley Professional.
- Millett, S., & Tune, N. (2015). _Patterns, principles, and practices of domain-driven design._ Wrox.