An elevator system is a combination of mechanical components and software logic used in multi-story buildings to transport people or goods vertically between floors.
Modern elevator systems typically consist of one or more elevator cars (also called lifts), each controlled by an embedded software system that manages a range of operations, including:
In this chapter, we will explore the low-level design of an elevator system in detail.
Lets start by clarifying the requirements:
Before starting the design, it's important to ask thoughtful questions to uncover hidden assumptions and better define the scope of the system.
Here is an example of how a conversation between the candidate and the interviewer might unfold:
Candidate: Should we assume a single elevator or support multiple elevators operating in the same building?
Interviewer: Let’s design for a system with multiple elevators in the same building.
Candidate: Should the system handle both internal requests (floor buttons inside the elevator) and external requests (hall calls from each floor)?
Interviewer: Yes, the system should support both internal and external requests.
Candidate: Should we follow a specific elevator scheduling algorithm, like SCAN or LOOK, or is a basic first-come-first-serve strategy sufficient?
Interviewer: For this version, use a simple scheduling strategy like nearest elevator first. However, the design should be extensible enough to support pluggable scheduling algorithms in the future.
Candidate: Should the elevators display their current floor and movement direction (up/down)?
Interviewer: Yes, each elevator should display its current floor and movement direction in real-time.
After gathering the details, we can summarize the key system requirements.
After the requirements are clear, lets identify the core entities/objects we will have in our system.