YouTube

Session 11 of Software Lessons, “Programming in Python: Object-Oriented (OOP) Part 3 (Factory Pattern),” runs about 29 minutes.

What this session covers

  • The factory design pattern

Key ideas

  • The factory pattern is a creational pattern that puts object creation in one place instead of scattering constructor calls through the code.
  • The calling code asks the factory for an object and does not need to know which concrete class is built.
  • Supporting classes often share a common interface, so the factory can return any of them interchangeably.
  • Keeping creation logic in a factory makes it easier to add a new kind of object later without changing the callers.