GithubHelp home page GithubHelp logo

jnwelzel / priceyyy Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 43 KB

Calculate cart prices using 2 separate json files: one for the cart and one for the base prices

Home Page: http://take-home-test.herokuapp.com/new-product-engineer

Java 100.00%
java8 cli maven clean-architecture

priceyyy's Introduction

Maintainability Test Coverage

Algorithm

  1. Iterate through cart items
  2. Get item data, but from the base price list
  3. Check which options are valid for this cart item using the data from the previous step and filter out the invalid options
  4. Find the base price from the base price list for each item in the cart using its options + product type as unique keys
  5. Perform price calculation using the data from both objects for each cart item

Price Calculation Formula

  • (base_price + round(base_price * artist_markup in cents)) * quantity

Architecture

  • I'm using Uncle Bob's Clean Architecture in combination with domain-driven design. Basically I'm grouping my Clean Architecture concerns (gateways, use cases, presenters, etc) by their respective domains.

How I did it

  1. Abstracted the domain problem without caring about the underlying implementation using interfaces
  2. Started working on the underlying implementations
    1. Cart item price calculator + tests
    2. Whole cart price calculator + tests
    3. Gateway that fetches the item with the base price from the JSON file + tests
  3. Implemented the CLI app + tests
    1. The AppTest can be considered an integration or end to end test since it encompasses the whole logic of the core package

Resources

How to run it

  • run mvn install
  • then either java -jar target/priceyyy-1.0.0-SNAPSHOT-jar-with-dependencies.jar <cart_file_path> <base_prices_file> or java -jar target/priceyyy-1.0.0-SNAPSHOT-jar-with-dependencies.jar for interactive mode

priceyyy's People

Contributors

jnwelzel avatar

Stargazers

 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.