Giter Site home page Giter Site logo

miles's Introduction

miles

A coding exercise around tracking driver's history.

Problem Statement

Please see the requirements file for details on the problem statement.

Getting Started

This project was built using specific versions of Node and yarn, found in the package.json file. It is assumed both are installed and available.

Install dependencies:

$ yarn

Run the example input:

$ yarn run:example

Run the tests:

$ yarn test

Application Overview

The requirements of the project state that it should take input from a file, process each line within that file as an instruction, and produce some output to the console. To assist with testing, the file processing was handled outside of the main code paths. The src/index.js file handles processing the input.txt file, but delegates most of the responsibility to src/System.js.

Below is an overview of the major classes within the application:

System

This class is responsible for containing state on the system as a whole, as it contains a set of Drivers along with their associated Trip data. It can then generate a report once the list has been fully processed.

The calculation for the report is done at the time of request, and some of that processing is done by the Driver class itself. The requirements state that the report should be output to console. Testing console output can be a bit tricky, so this part was isolated and ignored in code coverage. The bulk of the processing for the report is then tested outside of the console logging.

Finally, this class was constructed to support additional commands if needed, by delegating to the command's class to process the instruction.

Driver

This class contains the state on an individual driver, along with details on the trips made by that driver. When requested, this class can generate detailed data on the driver's history useful in the System report.

The Driver instance collects the details of the Trip, but doesn't store the trip itself. This was done because the driver data needs this high level detail to calculate the report information, after all trips have been processed.

Trip

This class is a representation of a single trip instruction, useful to grab data about that trip.

miles's People

Contributors

dylants avatar

Watchers

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