Important things

302 http response with Location header for url redirection(GET and Head) - 307 for temporary redirection ,==> Spring Sleuth - tracing in microservices, ==> https://astikanand.github.io/techblogs/high-level-system-design/design-bookmyshow, https://www.hellointerview.com/learn/system-design/in-a-hurry/introduction

Wednesday, 9 June 2021

design elevator using event driven programming

 We can divide into three main components:

  1. User

    • User presses the floor button (can be up or down direction) to summon the elevator.
    • User presses the elevator button to go to the destination floor.
  2. Button

    • An elevator has buttons (ElevatorButton) inside allowing user to choose the destination floor.
    • Each floor has two buttons (FloorButton) to summon the elevator to go up or down from that floor.
    • When the user presses the button, it illuminates.
    • When the elevator reaches the desired floor, the button stops illuminating.
    • Calls placeRequest() to insert into the ElevatorRequest queue when button is pressed.
  3. Elevator

    • Open or close door.
    • Moves up/down.
    • Stores states such as direction (up/down), speed, currentFloor.

We need a queue to store all request, this can all be encapsulated in an ElevatorRequests class. When a user presses a button, this request has to be served and is added to the processing queue. Elevator requests can be scheduled using different scheduling algorithms. ElevatorController controls the elevator by giving it instructions such as move up/down, or start/shutdown. The elevator controller reads the next elevator request and serves it.

This diagram may help :)

0_1462439050435_elevator-class diagram.png


No comments:

Post a Comment