Skip to content
Preptima
mediumConceptDesignMidSenior

When is a factory the right answer, when is a builder, and when should you just call the constructor?

7 min readUpdated 2026-08-15

Answer

Short answer

A constructor is the default and needs no justification.A static factory earns its place when construction can return a cached or alternative implementation, or needs a name; a builder when there are many optional fields.

Keep creational patterns explicit in the answer because that is the concept the interviewer is actually trying to test. A good creational patterns explanation names the trade-off, the failure mode, and the evidence you would use before choosing. Use creational patterns once more at the decision point so the answer reads as judgement rather than a detached example.

Keep creational patterns explicit in the answer because that is the concept the interviewer is actually trying to test. A good creational patterns explanation names the trade-off, the failure mode, and the evidence you would use before choosing.

Was this answer helpful?

Likely follow-ups

  • How would you make a builder reject an object missing a required field at compile time?
  • What does a dependency-injection container give you that a singleton does not?
  • Why is an enum the safest way to implement a singleton in Java if you must have one?
  • When does a factory method belong on the type it creates, and when does it belong on a separate class?

Related questions

Further reading

Related Topics