Every LLD interview eventually reaches the same moment: a behavior that varies.
Payment can be card, UPI, or wallet. Parking spots can be assigned nearest-first or
cheapest-first. Feeds can be ranked by recency or relevance. Reach for if-else and
you've told the interviewer everything they need to know. Reach for Strategy and the
conversation changes.
The shape
Strategy has three parts: a context that needs a behavior, an interface that names the behavior, and concrete strategies that implement it. The context never knows which concrete strategy it holds. That's the entire trick.
members only
This lesson is for members
Already a member? Sign in with your email and password and this lesson unlocks instantly.
Sign in →Your account does not hold a membership yet, and self-serve purchase is not open in this environment. Reach us via the contact page and we will set you up.