Design Patterns are Easy inside an IoC Container
summary
Shows a concrete refactor of a flight-quoting service that replaces nested if/else discounts with a Spring-based executor that injects all beans into a Map and auto-discovers strategy beans by name. Uses Spring components, sorting by grouping priority and inner priority, then for each group applies the first supporting rule (chain-of-responsibility/strategy hybrid). Example: €1,000 fares get 20% or 5% rules across six groups, producing €720 after reductions; new rules add by dropping a @Component class — service code never changes.
AI-written summary · about
chapters (10)
- 0:00Introduction and speaker intro
- 3:49Flight ticket system overview
- 9:41Problems with nested conditionals
- 13:18Design patterns for refactoring
- 18:23Strategy pattern implementation
- 23:23Rule grouping and execution
- 30:17Discount strategy executor
- 35:59Benefits of IOC container
- 37:26Spring-specific tips
- 39:13Q&A and closing
