LLD - Behavioral Design Patterns — Part 1In a system using the Strategy pattern, how can you combine it with the Factory pattern to improve scalability?AUse Factory pattern to replace Context class.BUse a Factory to create Strategy instances based on input, then inject into Context.CReplace Strategy pattern with Factory pattern entirely.DAvoid using Factory; create strategies manually everywhere.Check Answer
Step-by-Step SolutionSolution:Step 1: Understand combining patternsFactory pattern creates objects without exposing creation logic.Step 2: Apply to Strategy patternUsing Factory to create Strategy objects based on input decouples creation from usage, improving scalability and maintainability.Final Answer:Use a Factory to create Strategy instances based on input, then inject into Context. -> Option BQuick Check:Factory creates strategies; Context uses them [OK]Quick Trick: Factory creates strategies; Context uses them [OK]Common Mistakes:MISTAKESReplacing Strategy with FactoryConfusing roles of Context and FactoryCreating strategies manually everywhere
Master "Behavioral Design Patterns — Part 1" in LLD9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepArchTryChallengeDesignRecallScale
More LLD Quizzes Behavioral Design Patterns — Part 1 - Template Method pattern - Quiz 1easy Behavioral Design Patterns — Part 2 - Memento pattern - Quiz 1easy Behavioral Design Patterns — Part 2 - Visitor pattern - Quiz 4medium Design — Elevator System - Why elevator design tests state machines - Quiz 6medium Design — Library Management System - Notification system - Quiz 14medium Design — Library Management System - Fine calculation - Quiz 12easy Design — Parking Lot System - Why parking lot is a classic LLD problem - Quiz 1easy Design — Tic-Tac-Toe Game - Command pattern for undo - Quiz 13medium Design — Tic-Tac-Toe Game - Extensibility (NxN board, multiple players) - Quiz 8hard Design — Tic-Tac-Toe Game - Command pattern for undo - Quiz 1easy