Summary & Key Takeaways
Design Recap
Let's retrace our journey from blank page to working system.
| Tutorial | What We Did | Key Output |
|---|---|---|
| Getting Ready | Scoped the problem, identified real-world context | Problem boundaries, learning goals |
| Requirements | Defined R1-R10 functional + NF1-NF5 non-functional | Requirement specification |
| Use Case Diagram | Identified 3 actors, 10 use cases | Actor-use case relationships |
| State Machine | Modeled elevator states + door sub-states | 2 state machines with transitions |
| Class Diagram | Designed 18 classes, interfaces and enums | Complete structural blueprint |
| Scheduling Algorithms | Implemented FCFS, SCAN, LOOK with traced examples | Algorithm comparison, complexity analysis |
| Code Implementation | Full Python + Java for every class | Runnable code matching the class diagram |
| Design Patterns | Justified Strategy, State, Observer choices | Pattern rationale + rejected alternatives |
| Testing & Edge Cases | Unit + integration tests, 6 edge cases | Comprehensive test coverage |
Architecture at a Glance

Component count: 4 enums + 2 interfaces + 12 classes = 18 total. This is typical for a medium-complexity design problem.
Relationship summary:
- Composition: ElevatorSystem owns Elevators, Floors, and the Dispatcher. Elevator owns its Door and ElevatorPanel. Floor owns HallButtons and FloorDisplay.
- Association: Dispatcher references Elevators and a SchedulingStrategy. Elevator serves its Requests and notifies its ElevatorObservers.
- Implementation: FCFSStrategy, SCANStrategy, LOOKStrategy implement the SchedulingStrategy interface. FloorDisplay implements ElevatorObserver.
- Dependency: HallButton and ElevatorPanel create Request objects. Elevator uses the SchedulingStrategy handed to move(), and the Direction and ElevatorState enums; Door uses DoorStatus; Request uses RequestType.
Patterns Applied
| Pattern | Where Applied | Why This Pattern |
|---|---|---|
| Strategy (Fundamentals S12) | Scheduling algorithms — SchedulingStrategy interface with 3 implementations | Runtime algorithm swapping without modifying Dispatcher |
| State (Fundamentals S4) | The car's one ElevatorState enum, set only by move() and stop(), read by the strategies to pick a car | Clean state transitions in one place; the car never moves with its doors open — move() closes them before it leaves |
| Observer (Fundamentals S12) | Floor displays updated via ElevatorObserver | Decouples elevators from display components, easy to add new observer types |
SOLID Compliance
Our design aligns with all five SOLID principles:
Single Responsibility (SRP): Each class has one reason to change.
Elevatormanages car state and movement — NOT scheduling.Dispatchermanages request routing — NOT elevator mechanics.Doormanages open/close — NOT elevator state transitions.
Open/Closed (OCP): The system is open for extension, closed for modification.
- Add a new scheduling algorithm → implement
SchedulingStrategy, no changes to Dispatcher or Elevator. - Add a new observer (monitoring dashboard) → implement
ElevatorObserver, no changes to Elevator.
Liskov Substitution (LSP): Any SchedulingStrategy implementation can replace another without breaking the system. FCFSStrategy, SCANStrategy, and LOOKStrategy are fully interchangeable.
Interface Segregation (ISP): SchedulingStrategy has only 2 methods — both needed by any scheduling algorithm. ElevatorObserver has only 1 method. No client is forced to implement unused methods.
Dependency Inversion (DIP): Dispatcher depends on the SchedulingStrategy abstraction, not on concrete strategies. Elevator depends on the ElevatorObserver abstraction, not on concrete displays.
Extensions to Explore
Interview follow-ups often ask "how would you extend this?" Here are five realistic extensions and how our design accommodates them:
1. Weight/Capacity Limits
Add current_load and max_capacity to Elevator. Modify should_stop() to skip floors when full. Update select_elevator() in strategies to deprioritize full elevators. No structural changes needed.
2. VIP/Priority Elevators
Add a priority field to Request. Create a PriorityLOOKStrategy that serves high-priority requests first. The Strategy Pattern makes this a drop-in addition.
3. Destination Dispatch
Instead of UP/DOWN hall buttons, passengers enter their destination at the lobby. Changes the request model (destination known upfront) and enables better grouping. Implement as a new DestinationDispatchStrategy — the Dispatcher interface stays the same.
4. Emergency Mode
Add EMERGENCY to ElevatorState. In emergency mode, all elevators go to floor 1, open doors, and disable new requests. Add an emergency() method to ElevatorSystem that triggers the transition on all elevators.
5. Energy Optimization
During low-traffic periods, park some elevators at strategic floors (e.g., lobby, middle floor) and idle others. Implement as a ParkingStrategy that the Dispatcher uses when request volume drops below a threshold.
Key Takeaways
1. Start with requirements, not code. We wrote R1-R10 and NF1-NF5 before drawing any diagrams. Requirements drive every design decision — the class diagram is a CONSEQUENCE of requirements, not a starting point.
2. UML is a communication tool, not a formality. Our use case, state machine, and class diagrams weren't bureaucratic artifacts — they directly shaped the code. Every class in the diagram appears in the implementation. Every state in the state machine maps to an enum value.
3. Patterns solve specific problems — don't force them. We used Strategy because we genuinely needed interchangeable algorithms. We used Observer because there's a true publish-subscribe relationship. We used enum-based State instead of full State classes because 4 states didn't justify the complexity. Always ask "what problem does this pattern solve HERE?"
4. Test edge cases early. Simultaneous requests, boundary floors, duplicate presses, and single-elevator scenarios expose design flaws that aren't visible in the happy path. We identified 6 edge cases and proved our design handles each one.
5. Design for the current requirements, extend for the future. Our system handles R1-R10 without over-engineering. But the Strategy Pattern, Observer Pattern, and clean class boundaries mean that capacity limits, VIP elevators, and emergency mode can be added WITHOUT restructuring existing code.
What to Say in the Interview
When presenting your Elevator System design, structure your answer in this order:
-
Clarify scope (2 min): "I'll design for N elevators in a single building with hall calls and cabin calls. I'm assuming no weight limits or emergency mode unless you'd like me to include those."
-
Requirements (3 min): List 5-6 key functional requirements. Mention non-functional considerations (thread safety, response time).
-
Key classes (5 min): Walk through the class diagram — ElevatorSystem, Elevator, Dispatcher, SchedulingStrategy, Floor. Highlight relationships (composition vs. association).
-
Patterns (3 min): Name each pattern, where it's used, and WHY — not just what it is. "We use Strategy for scheduling because we need runtime swapping between FCFS and LOOK."
-
One algorithm deep-dive (3 min): Trace SCAN or LOOK through a concrete example with 5-6 requests.
-
Edge cases (2 min): Proactively mention 2-3 edge cases and how your design handles them.
Total: ~18 minutes, leaving room for interviewer questions and extensions.