Design Patterns (GoF and modern)
Design Patterns (GoF and modern) practice
48 exercises and 48 quizzes from the lessons of this track. Sample tests run in your browser; what you pass is kept in this browser only.
Why patterns, and when not to use them
- Turn a greeting if/elif chain into a registry
- Quiz: What a design pattern is (and is not)
- Write the classes of a class diagram in Python
- Quiz: Reading UML class and sequence diagrams
- Replace six report subclasses with composition
- Quiz: The design principles behind the patterns
- Port a Java-style Strategy to idiomatic Python
- Quiz: How language features reshape patterns
- Remove three layers that never vary
- Quiz: When patterns hurt: cost, YAGNI and overuse
Creational patterns: Factory Method to Singleton
- Replace a parser switch with a registry
- Quiz: Factory Method: defer which class to create
- Add a widget family and a new widget type
- Quiz: Abstract Factory: families of related objects
- Make build() the gate of an HTTP request builder
- Quiz: Builder: step-by-step object construction
- Clone a group of shapes without sharing too much
- Quiz: Prototype: create objects by copying
- One load for every early caller of a rate card
- Quiz: Singleton: one instance and its real costs
Structural patterns: Adapter to Proxy
- Put a modern interface on a legacy weather client
- Quiz: Adapter: make incompatible interfaces fit
- Split shapes from the formats that draw them
- Quiz: Bridge: split abstraction from implementation
- An org chart where people and teams answer alike
- Quiz: Composite: treat parts and wholes alike
- Caching and timing decorators around a price service
- Quiz: Decorator: add behaviour by wrapping
- Put a facade in front of a report export
- Quiz: Facade: one simple door into a subsystem
- Share tree types across a forest of 200,000 trees
- Quiz: Flyweight: share immutable state at scale
- A caching proxy for a slow exchange-rate client
- Quiz: Proxy: control access to another object
Behavioral patterns: algorithms and requests
Behavioral patterns: state and communication
- A price ticker whose subscribe() returns an unsubscribe function
- Quiz: Observer: notify subscribers of changes
- A booking desk that coordinates a room, calendars and a notifier
- Quiz: Mediator: centralise many-to-many talk
- Undo for a sign-up wizard, with a capped history and JSON saves
- Quiz: Memento: snapshots that keep state private
- An order lifecycle with guarded transitions and repeat-safe events
- Quiz: State: behaviour that changes with state
Modern patterns for application code
- Pass a converter its client, clock and logger
- Quiz: Dependency injection and the composition root
- Take nine checks for None out of a checkout
- Quiz: Null Object, Special Case and Option types
- Split money by ratios and round a discount half to even
- Quiz: Value objects, immutability and money
- A unit of work for orders and stock
- Quiz: Repository, Unit of Work and Identity Map
- A cart reducer with a coupon and undo
- Quiz: MVC, MVP, MVVM and one-way data flow
- A typed event bus with priorities and failure isolation
- Quiz: In-process event bus and domain events
Modern patterns for resources, runtime and composition
- A bounded buffer pool with timeouts, reset and usage counts
- Quiz: Object pools, thread pools, producer-consumer
- A plugin registry with versions, hooks and isolated failures
- Quiz: Plugins and the microkernel pattern
- A resource scope that cleans up in reverse order
- Quiz: RAII, scoped resources and type-state
- Order validation as pure functions that return results
- Quiz: Functional patterns that replace classes
- A fixed-timestep loop with component systems
- Quiz: Game loop, update method and components
Resilience patterns as code
- A retry policy with full jitter and Retry-After
- Quiz: Retry with exponential backoff and jitter
- A circuit breaker with a ratio, a floor and trial calls
- Quiz: Circuit breaker: fail fast, recover safely
- Best quote before a deadline, with the losers cancelled
- Quiz: Timeouts, deadlines and cancellation
- An order saga with a step log and an outbox in SQLite
- Quiz: Idempotency keys, outbox and saga in code
Patterns in standard libraries
Anti-patterns and refactoring to patterns
- Split a booking desk into two classes and a facade
- Quiz: Anti-patterns: god objects and golden hammers
- Fix four Python traps in pattern code
- Quiz: Language-specific traps when applying patterns
- Replace a repeated switch on kind with polymorphism
- Quiz: Code smells that point to a pattern
- Write characterization tests that kill three mutants
- Quiz: Refactoring safely with characterization tests
- Remove a needless Singleton and its one-product factory
- Quiz: Refactoring toward, and away from, patterns
Choosing patterns in design reviews and LLD rounds
- Write the Sweep scheduler and leave the car as it is
- Quiz: Choosing a pattern: a problem-first map
- Turn the notifier's options into stacked decorators
- Refactor the ride to State with every test green
- Quiz: Refactoring katas with characterization tests
- Code the scheduler and pass both change requests
- Quiz: Timed LLD mock rounds focused on patterns
Results here are what this browser has checked: feedback for you, not proof. They stay on this device; your Learn progress can be exported to a file. · Back to the Design Patterns (GoF and modern) track