GithubHelp home page GithubHelp logo

sa-exercise's Introduction

SA-EXERCISE

Technologies used

  • .NET Core 3.1.302
  • Console application
  • LINQ

Tools used

  • Visual Studio Code 1.42.1 for Mac OS
  • EditorConfig

Patterns in use

  • Factory
  • Command
  • Repository (ad hoc implementation)
  • ViewModel
  • Mediator
    • The TripCommandOrchestrator uses an ad hoc version of the Mediator pattern.
    • I would have used MediatR to dispatch the command as actions and have a separate command/handler class operate on the given CommandToken.

Challenges

  • The requirement "Discard any trips that average a speed of less than 5 mph or greater than 100 mph" was not immediately clear to me.
    • I was not sure whether we were excluding trip speeds of less than 5 MPH or over 100 MPH since the example provided did not showcase this scenario. In addition, this requirement doesn't explain why Bob appears in the results since there are no trip entries for him.
    • I tried asking recruiter for clarification but my email was not answered in time.
  • I am getting inconsistent results for Dan in example file.
    • The expected output for Dan is:
      • Dan: 39 miles @ 47 mph
    • However, my calculations for the average speed is off by 3. I even did this by hand and derived the same calculation (Average speed for Dan is 50):
      • Dan: 39 miles @ 50 mph
    • I tried manipulating the distances read in and calculated speeds by obtaining the floor value (Math.Floor()) but the least I got was 48 mph.
    • Having someone to talk to for clarification would have helped me to understand what I was missing.
    • This is just an example of unclear requirements. In a real world situation, I would have spoken with the BA to understand the requirements and possibly worked with a tester during a 3-Amigo session to derive test cases or identify missing scenarios/edge cases.

What I would do differently

  • Implement dependency injection.
  • Use asynchronous methods.
  • Organize solution into multiple projects:
    • Core
    • Infrastructure
    • Data
    • Main (console app)
    • etc.
  • Organize files into folders (models, repositories, services, etc.).
  • Add error handling logic.
  • Refactor Driver Repository to use Entity Framework Core with an in-memory database.
  • Add unit tests.
  • Improve TripFileTokenizer so that it is testable.

Executing

From the solution root:

$ dotnet run --project ./src/Mjv.TripReportGenerator

When prompted for the file name, enter

example-trip.txt

Example execution

Enter path to trip file:
example-trip.txt
You entered: example-trip.txt

REPORT:
=======
Alex: 42 miles @ 34 mph
Dan: 39 miles @ 50 mph
Bob: 0 miles

sa-exercise's People

Contributors

mariojvargas avatar

Watchers

 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.