Low level system design — Parking Lot Design Part — II
Code implementation for the Parking lot system design
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 class contains all the common behaviours which are applicable to other vehicles like in this example MotorCycle and Car
Parking spot:
- ParkingSpot class contains all the common behaviours which are applicable to other Spots like in this example CarSpot and MotorcycleSpot
Parking floor:
-
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:
-
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 🌟🌟🌟
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