Skip to main content

Summary

Pattern Comparison

PatternWhen to ApplyStrengthsCaveatsCommon Use Cases
Template MethodCommon structure with slight variationsEnforces structure, easy to shareInherits from base class (less flexible)Save operations, batch jobs
StrategyMain goal is to switch logic dynamicallyHighly flexible and testableCan lead to many small classesNotifications, calculation logic
BridgeMultiple dimensions of variationSeparates abstraction from implementationCan overcomplicate the designUI × Output format, renderers
FlyweightRepeated structures with shared stateReduces memory use, lightweightRequires external state managementIcons, seats, text rendering
PrototypeCopy from a base template and modify differencesEasy duplication and reuseBe cautious with side effects on cloneUI components, notifications, settings

Choosing the Right Pattern

  • Want to isolate just the differing parts → Template Method
  • Need flexible switching of logic → Strategy
  • Multiple axes of variation → Bridge
  • Repeating structures with shared data → Flyweight
  • Want to clone a base and apply changes → Prototype

Team Discussion Snippets

  • “The differences embedded in this common process could be extracted as hooks using Template Method.”
  • “This logic fits nicely into a Template Method — we just implement the variable parts.”
  • “If you want to swap behavior flexibly, Strategy might be a better fit.”
  • “Extracting this into Strategy lets us switch logic dynamically.”
  • “The notification type and content both vary — this calls for a Bridge to separate concerns.”
  • “Two dimensions of change? Sounds like a good case for Bridge to keep things clean.”
  • “We're creating the same icons over and over — consider using Flyweight to share them.”
  • “This notification structure could benefit from Prototype. Clone the base and customize.”