Skip to main content
PProfileMatch
← Path

Design Patterns · Behavioral Design Patterns: Strategy, Observer and Command in Python

0 XP
  1. 1 current stop: learning
  2. 2 upcoming
  3. 3 upcoming
  4. 4 upcoming
  5. 5 upcoming

Finish after stop 5

Stop 1 of 5 · Courier depot: the rate card keeps changing

Trick to keep in mind+3 XP

Strategy swaps the how. Observer tells whoever cares. Command packages an action.

Match the pain to the pattern. When one rule keeps changing and checkout has to be edited each time, put the rule behind a fixed signature and inject it: that is strategy. Observer is about notifying an unknown set of listeners, command is about turning an action into an object you can queue or undo, and singleton is about instance count.

Read it once, then a question tests whether the trick stuck.