GithubHelp home page GithubHelp logo

anomaly2104 / lld-parking-lot Goto Github PK

View Code? Open in Web Editor NEW
127.0 6.0 136.0 215 KB

Repository for low level design solution of parking lot

Shell 1.19% Ruby 0.41% Java 98.40%
parking-lot system-design lld oops oops-in-java object-oriented-programming design-patterns design-principles low-level-design low-level-programming

lld-parking-lot's Introduction

Video explanation:

https://youtu.be/7IX84K9g23U

Connect with me and my offerings:

https://enginebogie.com/u/anomaly2104

LLD Cohort:

https://enginebogie.com/u/anomaly2104/offerings/PATH/e6cce7f1-6a56-4fe3-bb82-48e1876e4596

Multi-threading Cohort:

https://enginebogie.com/u/anomaly2104/offerings/PATH/e9522ac1-4e4c-4217-92ba-f691f34c321b


Low Level System Design - Parking lot

Problem Statement

Check here

Project Requirements

  • JDK 1.8
  • Maven
  • For Unit Tests:
    • Junit 4
    • Mockito

Compiling/Building and running the unit tests

Go to the project root folder and then run: ./bin/setup.sh

Runing the project

NOTE: Before running, please make sure you do the above setup step. Otherwise it will not run. The project can be run as follows in one of the two ways:

  1. Using file based input:: It accepts a filename as a parameter at the command prompt and read the commands from that file.
    ./bin/parking_lot.sh <input_filepath>
    Example: ./bin/parking_lot.sh ./file_input.txt
  2. Using file based input:: This will run the program in the interactive shell mode where commands can be typed in.
    ./bin/parking_lot.sh

Further Enhancements:

  • Dependency injection: Currently dependencies are injected manually. We can use some dependency injection framework like spring.
  • Exit command: Exit command is currently coupled with interactive mode only which makes it non-reusable.
  • Parking strategy: Parking strategy is currently associated with ParkingLotService. Instead of that, it makes more sense to associate it with ParkingLot.
  • Mode: Mode checking is currently done in main function directly. There could be a factory for that.

lld-parking-lot's People

Contributors

anomaly2104 avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

lld-parking-lot's Issues

Getting error in test, when running `mvn clean install`

Tests in error:
testCorrectSlotNumberForNonExistingRegistrationNumber(com.uditagarwal.commands.SlotForRegNumberCommandExecutorTest)
testInvalidCommand(com.uditagarwal.commands.SlotForRegNumberCommandExecutorTest): Could not initialize class org.mockito.internal.creation.cglib.ClassImposterizer$3
testCorrectSlotNumberForValidRegistrationNumber(com.uditagarwal.commands.SlotForRegNumberCommandExecutorTest): Could not initialize class org.mockito.internal.creation.cglib.ClassImposterizer$3
testValidCommand(com.uditagarwal.commands.SlotForRegNumberCommandExecutorTest): Could not initialize class org.mockito.internal.creation.cglib.ClassImposterizer$3
testCarsWithAColor(com.uditagarwal.commands.ColorToRegNumberCommandExecutorTest): Could not initialize class org.mockito.internal.creation.cglib.ClassImposterizer$3
testInvalidCommand(com.uditagarwal.commands.ColorToRegNumberCommandExecutorTest): Could not initialize class org.mockito.internal.creation.cglib.ClassImposterizer$3
testValidCommand(com.uditagarwal.commands.ColorToRegNumberCommandExecutorTest): Could not initialize class org.mockito.internal.creation.cglib.ClassImposterizer$3
testWhenNoCarsFoundWithAColor(com.uditagarwal.commands.ColorToRegNumberCommandExecutorTest): Could not initialize class org.mockito.internal.creation.cglib.ClassImposterizer$3
testCommandExecutionWhenParkingSucceeds(com.uditagarwal.commands.ParkCommandExecutorTest): Could not initialize class org.mockito.internal.creation.cglib.ClassImposterizer$3

Need of creating a refrence to hashmap

Can you help me in understanding the need of creating a new reference for hashmap slots named allSlots using the getter method? Considering we can use the class variable slots directly as this.slots.

final Map<Integer, Slot> allSlots = getSlots();
if (!allSlots.containsKey(slotNumber)) {
allSlots.put(slotNumber, new Slot(slotNumber));
}
return allSlots.get(slotNumber);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.