Bird
0
0
LLDsystem_design~12 mins

Why elevator design tests state machines in LLD - Architecture Impact

Choose your learning style9 modes available
System Overview - Why elevator design tests state machines

An elevator system moves people between floors safely and efficiently. It must handle requests, move up or down, open and close doors, and respond to emergencies. Testing it as a state machine helps ensure it behaves correctly in all situations.

Architecture Diagram
  +---------+       +-------------+       +------------+       +---------+
  |  User   | --->  | Elevator    | --->  | Controller | --->  | Sensors |
  +---------+       | State       |       +------------+       +---------+
                    | Machine    |            |                  |
                    +-------------+            |                  |
                          |                    |                  |
                          v                    v                  v
                    +-------------+      +------------+     +------------+
                    | Motor       |      | Door       |     | Emergency  |
                    | Controller  |      | Controller |     | System     |
                    +-------------+      +------------+     +------------+
Components
User
actor
Person who requests elevator service by pressing buttons
Elevator State Machine
service
Manages elevator states like moving, stopped, doors open/closed
Controller
service
Processes inputs and commands motor and doors accordingly
Sensors
hardware
Detect elevator position, door status, and safety conditions
Motor Controller
hardware
Controls elevator movement up or down
Door Controller
hardware
Controls opening and closing of elevator doors
Emergency System
hardware
Handles emergency stops and alarms
Request Flow - 6 Hops
UserElevator State Machine
Elevator State MachineController
ControllerMotor Controller
SensorsElevator State Machine
ControllerDoor Controller
Emergency SystemElevator State Machine
Failure Scenario
Component Fails:Elevator State Machine
Impact:Elevator may enter incorrect states causing unsafe or stuck behavior
Mitigation:Use thorough state machine testing and fallback safe states to stop elevator safely
Architecture Quiz - 3 Questions
Test your understanding
Why is the elevator system modeled as a state machine?
ATo reduce the number of sensors needed
BTo speed up the elevator motor
CTo clearly define and control all possible elevator states and transitions
DTo allow users to control the elevator remotely
Design Principle
Modeling the elevator as a state machine ensures all possible states and transitions are explicitly handled. This approach helps prevent unsafe or unexpected behavior by making the system predictable and testable.