Skip to main content
Loading page…
Python Mastery
Chapter 20
Lesson 1 of 4
Creational Patterns
Contents
Notes
Tutor
Concept
What Are Creational Patterns — and Why Do They Matter?
Loading activity…
Previous
1 / 12
Continue
Contents
Notes
Discussion
Tutor
28 min
12 activities
0 of 12 done
In this lesson
1
What Are Creational Patterns — and Why Do They Matter?
2
Factory Functions and Factory Methods
3
Worked Example: Pluggable Serializer Factory
4
The Builder Pattern
5
Singleton: The Pythonic Way
6
Dependency Injection via Parameters
7
Frozen Dataclasses and Value Objects
8
Annotated: Factory Classmethod on a Value Object
9
Practice: Implement a Shape Factory
10
Why Prefer a Module Over a Classic Singleton Class in Python?
11
Gotcha: Builder Mutation Leak
12
Dependency Injection: The Core Benefit
Objectives
Implement factory functions and factory methods in idiomatic Python
Apply the builder pattern using method chaining or dataclasses
Explain why a module is the Pythonic singleton and when to use it
Wire dependencies via constructor parameters for testability
Chapter 20 · Design Patterns in Python
Creational Patterns
Structural Patterns
Behavioral Patterns
Pythonic Patterns & Anti-Patterns
Previous: Pydantic in the Real World
Next: Structural Patterns