Giter Site home page Giter Site logo

red-badger-test's Introduction

Design

The structure of the solution is modeled with Domain-Driven Design. It has a domain layer which defines the MarsMap and Robot entities. A service called

Key concepts

1. Domain

  • MissionMap interface to allow for missions to different planets. MarsMap is the only implementation at the moment
  • Robot entity for basic robot functionality like turning and calculating next position
  • Orientation, Position, RobotReport, RobotStatus, Scent - helper classes that don't need an ID
  • RobotMovementService enforces the invariants of the mission (e.g. robots get lost, don't move if there's a scent, etc)

2. Application

The application layer uses the Command pattern with a really basic command handler implementation. Ideally a more robust one would be implemented with proper DI registration for each command to avoid manually checking the instruction letter (in RobotInstructionService)

  • CommandInvoker and RobotCommand - generic interfaces to provide an extensible framework for other commands
  • RobotInstructionService - processes a command
  • MarsMissionRunner deploys a robot instance and sends instructions to it. This orchestrates concrete classes but should really use dependency injection. Maintains state of the mission

The solution makes some assumptions about current and future use cases. One such assumption is next position is not automatically set in the Robot class but rather calculated and then set on the object by the MarsRobotMovementService so that domain rules can be easily enforced from the service

Instead of using a dependency injection framework, the solution uses the MarsMissionRunner class to orchestrate concrete classes and run the mission

Future improvement suggestions:

  • Proper Dependency Injection
  • Loading of robots from a database
  • Logging
  • Dedicated Validator services to allow for more flexible validation
  • Improved Command pattern structure for the application layer

How to run

For a basic CLI interface, run main() from Main.kt

Alternatively - run all tests. Tests for MarsMissionRunner are essentially integration tests that use concrete implementations instead of mocking dependencies on other layers like the unit tests for other classes

red-badger-test's People

Contributors

martinzokov 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.