Software Engineering Architecture Lab

Factory Method Pattern

Let a method decide which concrete class to instantiate. A creational pattern in the Design Patterns (GoF) catalog. With Java/Spring code.

Let a method decide which concrete class to instantiate.

Family
Design Patterns (GoF)
Category
Creational
Source
Gamma, Helm, Johnson, Vlissides · Head First Design Patterns

More creational patterns

  • Abstract Factory — Create families of related objects that must be used together.
  • Builder — Construct complex objects step by step with readable code.
  • Prototype — Create new objects by copying a configured example.
  • Singleton — Guarantee one instance — usually better handled by your DI container.

All patterns