GithubHelp home page GithubHelp logo

construction-site-simulation's Introduction

Construction Site Simulator

This application is a comprehensive simulation for bulldozer drives. It allows bulldozer operators to send commands to operate a bulldozer, and simulate clearing of particular area.

How to Build

The project is configured via Maven. To build it from the project checkout directory, type:

mvn clean install

How to Run

To run the simulator, one input argument must be provided. This argument is a file-system path to a file with the map of an area to run the simulation on:

java -jar construction-site-simulator-[version]-spring-boot.jar [file path]

An example map is provided with the build of this program. The run the recent build with an example map, one may run within the checkout directory of the project:

java -jar target/construction-site-simulation-1.0-SNAPSHOT-spring-boot.jar src/test/resources/map.txt

When the program starts, the map is printed, and the user is asked to input commands to operate the bulldozer. At the end of the simulation the bill is printed.

Program Design

The program combines stateless services, stateful domain objects, and functional programming style actions.

Services are stored in the sub-package services and they trigger actions from the sub-package actions. The result of execution is modification of stateful objects from the sub-package domain.

The program runs in a loop until it is executed. This loop is executed from the main class App in the root package.

All the functionality is tested via JUnit.

Discussion

The project does not use any IoC framework such as Spring, but it is designed to use it easily - i.e. the services are designed with the dependency injection principle.

The project shows possible combination of stateless services and functional programming in Java. It has some limitations caused by not sufficient dynamicity of Java lambdas. For instance, the number of lambda arguments is not flexible, which means that some actions from ActionsFactory must define the input argument, even if it is not used (see, the x argument, which is ignored), because other actions do have an input argument.

The enum CommandType breaks the inversion-of-control principle as it directly injects dependencies from ActionsFactory. It is because enums are "static classes", and while they can be modified at run-time, there is no elegant way to inject their dependencies as part of their creation. For this reason ActionsFactory contains static methods, which are directly called from the enum creation. An alternative could be a standard class instantiated in more instances in replacement of enum items.

construction-site-simulation's People

Contributors

kjezek avatar

Watchers

 avatar

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.