design - What is your threshold to use factory instead of a constructor to create an object? -


What is your limit to using the factory instead of constructor to create an object?

  1. You always use the factory.
  2. You only use the factory, if you have nothing besides check for a futuristic check tap.
  3. You always use Constructor
  4. .. What are those cases ??

Pros and Cons

UPDATE: I am implementing a factory pattern in my project with a domain driven design. And one reason behind building factories is to reduce the noise in the domain model.

Thanks

If I have an abstract base class (or an interface), and There are several concrete derivative classes, and some arguments, according to which one of the concrete sections is formed. I apply that argument to the factory.


Comments