Low level system design — Parking Lot Design Part — II

Code implementation for the Parking lot system design

Madhan published on
2 min, 371 words

In continuation of my previous article, in this post we will look at the code implementation of the Parking lot system, which was solved using Typescript programming language, and following Test Driven Development (TDD) using Vitest unit test framework.

Vehicle:

Vehicle spot implementation

  • Vehicle class contains all the common behaviours which are applicable to other vehicles like in this example MotorCycle and Car

Parking spot:

Parking spot implementation

  • ParkingSpot class contains all the common behaviours which are applicable to other Spots like in this example CarSpot and MotorcycleSpot

Parking floor:

Parking floor implementation

  • ParkingFloor class has the access to parking spots and display board.

  • The getSpotTypeForVehicle private method determines which ParkingSpot should be mapped to a given vehicle.

Parking lot:

Parking lot implementation

  • The ParkingLot class serves as the system's entry point.

  • The ParkingLot class is declared using the singleton pattern, which limits class initialization to ensure that only one instance of the class can be created.

* * * *

Originally published on Medium

🌟 🌟 🌟 The source code for this blog post can be found here 🌟🌟🌟

GitHub - madhank93/learn-system-design

References:

[1] https://github.com/tssovi/grokking-the-object-oriented-design-interview

[2] https://www.youtube.com/watch?v=nnpT0WXifLk

[3] https://www.youtube.com/watch?v=tVRyb4HaHgw

[4] https://www.youtube.com/watch?v=7IX84K9g23U

[5] https://www.youtube.com/watch?v=DSGsa0pu8-k