Loading LLD design...
Design an object-oriented elevator system that manages multiple elevators in a building with M floors. The system handles external requests (floor buttons) and internal requests (cabin buttons), dispatches the optimal elevator using a pluggable strategy, and moves elevators using a SCAN/LOOK scheduling algorithm.
The controller coordinates all elevators, each of which maintains its own stop list and direction state. The dispatch strategy (nearest-elevator, zone-based, etc.) can be swapped at runtime.
External request (floor button)
A person on a floor presses UP or DOWN to request an elevator
Internal request (cabin button)
A passenger inside the elevator presses a destination floor
Dispatch elevator
Controller selects the optimal elevator for each external request
Move and stop
Elevator moves floor by floor, opening doors at requested stops
Direction management
Elevator continues in one direction, serving all stops, before reversing (SCAN/LOOK)
Multiple elevators
System manages N elevators across M floors concurrently
Pluggable dispatch strategy
Swap between nearest-elevator, zone-based, or other scheduling algorithms
Before diving into code, clarify the use cases and edge cases. Understanding the problem deeply leads to better class design.
Identify the primary actions users will perform. For a parking lot: park vehicle, exit vehicle, check availability. Each becomes a method.
Who interacts with the system? Customers, admins, automated systems? Each actor type may need different interfaces.
What are the limits? Max vehicles, supported vehicle types, payment methods. Constraints drive your data structures.
What happens on overflow? Concurrent access? Payment failures? Thinking about edge cases reveals hidden complexity.