Software Engineering Architecture Lab

Strategy: Pluggable Payment Methods

Replace a growing if/else over payment types with interchangeable processors. Lesson 2 of Level 4: Design Patterns. Based on Design Patterns.

Level 4 · Design Patterns · Lesson 2 of 13

Replace a growing if/else over payment types with interchangeable processors.

Continue learning

Try it hands-on

  • Design Pattern Playground — Add payment methods, discounts and order states to ShopFlow with and without patterns; count the classes you had to edit.

All lessons in Design Patterns

  1. Patterns Are Answers to Recurring Pain
  2. Strategy: Pluggable Payment Methods
  3. Factory Method & Abstract Factory: Creating the Right Thing
  4. Builder, and Why Singleton Is Usually a Trap
  5. Adapter: Taming Third-Party Payment Gateways
  6. Decorator: Adding Behaviour Without Touching the Core
  7. Facade & Proxy: Simple Front Doors and Smart Stand-ins
  8. Observer: Reacting to Order Events
  9. Command: Refunds, Retries and Queued Work as Objects
  10. State: An Order Lifecycle Without the Giant Switch
  11. Template Method: One Checkout Skeleton, Many Variations
  12. Chain of Responsibility: Validation & Fraud Pipelines
  13. Composite, Bridge, Mediator, Iterator & Prototype