A Clojure implementation of [Kata Nine: Back to the CheckOut @ Code Kata] (http://codekata.pragprog.com/2007/01/kata_nine_back_.html).
| Item | Unit Price | Special Price |
|---|---|---|
| A | 50 | 3 for 130 |
| B | 30 | 2 for 45 |
| C | 20 | |
| D | 15 |
Our checkout accepts items in any order, so that if we scan a B, an A, and another B, we’ll recognize the two B’s and price them at 45 (for a total price so far of 95). Because the pricing changes frequently, we need to be able to pass in a set of pricing rules each time we start handling a checkout transaction.
To some extent, this is just a fun little problem. But underneath the covers, it’s a stealth exercise in decoupling. The challenge description doesn’t mention the format of the pricing rules. How can these be specified in such a way that the checkout doesn’t know about particular items and their pricing strategies? How can we make the design flexible enough so that we can add new styles of pricing rule in the future?
Run the unit tests
$ lein test
Copyright © 2013 me?
Distributed under the Eclipse Public License, the same as Clojure.