/point-of-sale-kata-definition

Kata definition to practice TDD, please clone it and enjoy!

Primary LanguageKotlin

Point of sale - kata definition

TDD is important. TDD works. TDD is a professional discipline that all programmers should learn and practice. But it is not TDD that causes good or bad designs. You do that.

Uncle Bob

Description

Code kata to practice outside in tdd inspired by super market kata but slightly different.

The idea is to code a Point of Sale, by which we could calculate and checkout an ongoing sale in a supermarket.

Catalog

Product-id   Price   Description
--------------------------------
901234       1.50     Chips
507780       2.35     Red Bull

ACs

  • When a product is scanned, the price is shown in the display.
  • When a scanned product is not present, a message 'invalid product' is displayed.
  • Each time a product is scanned successfully, it will be added to the current digital shopping cart, keeping track of all the items for this sale.
  • If a product was added by mistake, we can remove it from the current cart by product-id, the price will be displayed in negative.
  • In any moment, we can cancel the current sale, clearing out the cart.
  • When the sale is finished, the point of sale will check out, calculating the total price and displaying it.

Rules

  1. RED: Create a unit tests that fails.
    1. Red means that the test fails, the assertion fails (You may have to write the minimal code to make the compiler happy)
  2. GREEN: Write code that makes that test pass.
    1. Make the tests pass by writing the minimal code necessary
  3. REFACTOR: Clean up the mess you just made.
    1. Write code that you are proud of
    2. Refactor old and new code

Hints

There are multiple ways to solve this exercise, as you can see there is no code to start with, try to solve in a scalable , maintainable and decoupled way.

Outside-in TDD

Resources