Parking Lot LLD — What I Learned Building It
I recently started practicing Low Level Design problems to strengthen my system design and backend thinking.
The second problem I picked was the classic Parking Lot System.
At first, it looked simple.
But while building it, I realized these problems are less about writing code and more about:
- Modeling real-world systems
- Managing state correctly
- Designing scalable abstractions
- Avoiding bad object-oriented practices
Requirements
The system supports:
- Multiple parking floors
- Different parking spot types:
- Small
- Medium
- Large
- Multiple vehicle types:
- Bike
- Car
- Truck
- Ticket generation at entry
- Fee calculation during exit based on parking duration
Initial Flow
After reading the requirements, this was the initial flow I designed:
| |

Then I converted it into a more structured object-oriented design.

Important Things I Learned
1. Static Methods Should Not Modify Instance State
One of the biggest mistakes I made initially was using static methods everywhere.
My first implementation looked something like this:
| |
This was incorrect because:
ticketsrepresents the state of a parking lot object- parking operations belong to a parking lot instance
- static methods should not manage mutable business state
I later refactored the design to use instance methods instead:
| |
This made the design much cleaner and aligned better with object-oriented principles.
2. Making Singleton Thread Safe
Since a parking lot should ideally have a single system instance, I implemented the Singleton pattern.
To make it thread-safe, I used:
volatile- synchronized block
- double-checked locking
| |
One thing I learned here:
volatile prevents instruction reordering and ensures all threads see the fully initialized object correctly.
Before this, I only knew Singleton theoretically.
Implementing it properly helped me understand concurrency concepts much better.
3. Small Real-World Improvements Matter
Initially, I only supported exiting using a ticket ID. But in real parking systems, users often lose tickets. Parking attendants usually search using vehicle registration numbers.
So I added:
| |
This also made me think about scalability. Right now this performs a linear search:
| |
For a production-scale system, maintaining:
| |
for active vehicles would provide constant-time lookups. That was another good reminder:
- System design is not only about classes and diagrams
- Choosing the right data structures matters equally
Final Thoughts
This problem looked easy at first.
But while implementing it, I learned:
- Better object-oriented design
- Singleton implementation
- Concurrency basics
- Importance of data structures
- Thinking beyond the “happy path”
Next, I’m planning to work on:
- BookMyShow LLD
- Food Delivery System
