- Clone this repository on your machine.
- Use your IDE of choice to complete the assignment.
- When you are finished with the solution and have pushed it to the repo, you can submit the assignment here.
We’ll be using a simple shopping cart, similar to those used by e-commerce websites, as the domain for this problem.
There’s no time limit for this task. We expect that you can give a representative piece of code in 1-2 hours.
Your solution should:
- be developed 'test-first'
- have good unit tests
- cover common paths
- be self-contained and not rely on external systems when running tests. Use fakes/ mocks/ stubs as you see fit.
- in a "real" project integration tests may use a network could run over the network but this is not required for this assessment.
We value simplicity as an architectural virtue and a development practice. Solutions should reflect the difficulty of the assigned task, and shouldn’t be overly complex. We prefer simple, well tested solutions over clever solutions.
Please avoid:
- A web, desktop, command line or any other kind of app
- Unnecessary layers of abstraction
- Unnecessary patterns/ architectural features that aren’t called for
Your code needs only to be driven by tests and can extend IOApp
The solution you produce must speak for itself. Multiple paragraphs explaining the solution is a sign that the code isn’t straightforward enough to understand on its own.
If there’s any ambiguity, please add this in a section at the bottom of the README. You should also make a choice to resolve the ambiguity.
The solution should demonstrate the use of functional programming concepts, in particular, the use of immutable data structures, referential transparency, and the use of the monads in dealing with effects.
We often use Cats in our projects, so we've provided all the boilerplate and dependencies in this template project. However, we are more interested in your use of functional programming techniques than the use of a library, so feel free to deviate from what we provide here.
Create a shopping cart package that facilitates 2 basic capabilities.
-
Add a product to the cart
- Specifying the product name and quantity
- Use the product name to discover the price from the Product API specified below
- Cart state (totals, etc.) must be available
-
Calculate the state:
- Cart subtotal (sum of price for all items)
- Tax payable (charged at 12.5% on the subtotal)
- Total payable (subtotal + tax)
- Totals should be rounded up where required
Base URL: https://equalexperts.github.io/
View Product: GET /backend-take-home-test-data/{product}.json
Available products
cheerios
cornflakes
frosties
shreddies
weetabix
The below is a sample with the correct values you can use to confirm your calculations
- Add 1 × cornflakes @ 2.52 each
- Add another 1 x cornflakes @2.52 each
- Add 1 × weetabix @ 9.98 each
- Cart contains 2 x cornflakes
- Cart contains 1 x weetabix
- Subtotal = 15.02
- Tax = 1.88
- Total = 16.90
- Can price change ?
- on the assumption it can change:
- prices are not cached as price accuracy is considered more important than performance optimization;
- if performance (or cost) for calling an external service to check the price becomes a problem, a cache could be added:
- an eventual cache implementation would need to make sure it is kept in sync with price updates (by either subscribing to price updates, if the price service supports it, or by pulling prices on a scheduled basis);
- on the assumption it can change: