Factory
A factory is a design pattern in which a class or method is dedicated to the task of creating other objects. Factories encapsulate the knowledge needed for complex object creation.
When the construction of an object becomes overly complex, or where it requires knowledge of the object’s internal data structures, it is a good practice to create a factory to simplify and abstract away the assembly operation.
The factory pattern is recommended in [domain-driven design] to encapsulate the logic needed to create [entities] and [value objects], ensuring that these are created in a consistent and valid state. Factories encapsulate the business rules for creation of business objects, and therefore they exist in the domain layer.