Coder Social home page Coder Social logo

supermarket-kata's Introduction

Implementation of supermarket kata found here

Prerequisites

  • Java 8
  • Maven

Running the tests

mvn clean test

Approach

Please note this is just part of the model of a real supermarket. My application assumes there are Products (with infinite stock) and several types of Promotions. I've also added a stubbed Basket that only calculates its total and discounted prices.

This kata is based on Uncle Bob's clean architecture. I've implemented inputs to the system as simple Transactions that emulate use cases.

The real challenge has been implementing flexible promotions. At the moment, the system supports:

  • single-buy promotions, e.g. "Buy one and pay £4 less"
  • multi-buy promotions where the discount is calculated over a set of products - e.g., "Buy 3 get 20% off"

I've used the strategy pattern to make the promotions flexible in terms of:

  • applicability - i.e. how many products are needed for the promotion to apply
  • discount - i.e. different types of discounts (like percent or value)

REST endpoints

For example for products:

Add a product: POST /supermarket/products

Remove a product: DELETE /supermarket/products/{sku}

Update a product: PUT /supermarket/products

Get a product: GET /supermarket/products/{sku}

supermarket-kata's People

Contributors

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