http://codekata.com/kata/kata01-supermarket-pricing/
Kata01: Supermarket Pricing
This kata arose from some discussions we’ve been having at the DFW Practioners meetings. The problem domain is something seemingly simple: pricing goods at supermarkets.
Some things in supermarkets have simple prices: this can of beans costs $0.65. Other things have more complex prices. For example:
- three for a dollar (so what’s the price if I buy 4, or 5?)
- $1.99/pound (so what does 4 ounces cost?)
- buy two, get one free (so does the third item have a price?)
This kata involves no coding. The exercise is to experiment with various models for representing money and prices that are flexible enough to deal with these (and other) pricing schemes, and at the same time are generally usable (at the checkout, for stock management, order entry, and so on). Spend time considering issues such as:
- does fractional money exist?
- when (if ever) does rounding take place?
- how do you keep an audit trail of pricing decisions (and do you need to)?
- are costs and prices the same class of thing?
- if a shelf of 100 cans is priced using “buy two, get one free”, how do you value the stock?
This is an ideal shower-time kata, but be careful. Some of the problems are more subtle than they first appear. I suggest that it might take a couple of weeks worth of showers to exhaust the main alternatives.
Goal
The goal of this kata is to practice a looser style of experimental modelling. Look for as many different ways of handling the issues as possible. Consider the various tradeoffs of each. What techniques are best for exploring these models? For recording them? How can you validate a model is reasonable?
- 1달러에 3개 ( 만약 4개나 5개를 사면 가격이 어떻게 되는거지? )
- 1파운드에 1.99달러 ( 4온스는 그럼 얼마지? )
- 두 개를 사면 하나가 무료인 경우 ( 그럼 세번째 아이템은 가격을 가지고는 있는 건가? )
- 분수형 돈이 존재 할까?
- 만약 그렇다면 언제 라운딩(rounding)이 발생할까?
- 가격 결정에 대한 감사 추척(audit trail)은 어떻게 유지할까?(그리고 해야 할 필요가 있을까?)
- 비용과 가격은 같은 클래스로 봐야 할까?
- 만약 한 선반의 100개의 캔을 "두 개 사면 하나 공짜"로 가격을 매겨 놓았다면, 재고에는 얼마의 값을 매겨야 할까?
Goal
'100.알고리즘 > 02. Code Kata' 카테고리의 다른 글
CodeKata (0) | 2015.11.02 |
---|