Skip to content

Commit 3132415

Browse files
committed
Add some future tasks to extend this and fix some typos
1 parent 8f87fbc commit 3132415

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

test-pnpm/shopping-cart-kata/README.md

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ We are building a shopping cart for an online grocery shop. The idea of this kat
1111

1212
### List of products
1313

14-
| **Name** | **Cost** | **% Revenue** | **Price per unit** | **Tax** | **Final price** |
15-
| ------------- | -------- | ------------- | ------------------ | ----------------------- | --------------- |
16-
| **Iceberg 🥬** | *1.55 €* | *15 %* | 1,79 € | *Normal (21%)* | 2.17 € |
17-
| **Tomato 🍅** | *0.52 €* | *15 %* | 0.60 € | *Normal (21%)* | 0.73 € |
18-
| **Chicken 🍗** | *1.34 €* | *12 %* | 1.51 € | *Normal (21%)* | 1.83 € |
19-
| **Bread 🍞** | *0.71 €* | *12 %* | 0.80 € | *First necessity (10%)* | 0.89 € |
20-
| **Corn 🌽** | *1.21 €* | *12 %* | 1.36 € | *First necessity (10%)* | 1.50 € |
14+
| **Name** | **Cost** | **% Revenue** | **Price per unit** | **Tax** | **Final price** |
15+
| -------------- | -------- | ------------- | ------------------ | ----------------------- | --------------- |
16+
| **Iceberg 🥬** | _1.55 €_ | _15 %_ | 1,79 € | _Normal (21%)_ | 2.17 € |
17+
| **Tomato 🍅** | _0.52 €_ | _15 %_ | 0.60 € | _Normal (21%)_ | 0.73 € |
18+
| **Chicken 🍗** | _1.34 €_ | _12 %_ | 1.51 € | _Normal (21%)_ | 1.83 € |
19+
| **Bread 🍞** | _0.71 €_ | _12 %_ | 0.80 € | _First necessity (10%)_ | 0.89 € |
20+
| **Corn 🌽** | _1.21 €_ | _12 %_ | 1.36 € | _First necessity (10%)_ | 1.50 € |
2121

2222
### List of discounts
2323

@@ -150,9 +150,12 @@ We are building a shopping cart for an online grocery shop. The idea of this kat
150150
```javascript
151151
export interface ShoppingCart {
152152
addItem(cartItem: CartItem): void;
153-
deleteItem(cartItem: CartItem): void;
154153
applyDiscount(discount: Discount): void;
155154
printShoppingCart(): void;
155+
// TODO
156+
removeItem(name: string): void;
157+
updateItemQuantity(name: string, quantity: number): void;
158+
getItems(): ReadonlyArray<CartItem>;
156159
}
157160
```
158161

@@ -162,15 +165,18 @@ export interface ShoppingCart {
162165

163166
##### Suggested Inside-Out Iterations (with TDD focus)
164167

165-
| Iteration | Focus | Why Start Here? |
166-
| --------- | ---------------------------------------- | -------------------------------------------- |
167-
| 1 | `Product` - price per unit and VAT logic | Small, atomic, pure — perfect TDD start |
168-
| 2 | `CartItem` - quantity & total price | Introduces aggregation, still isolated logic |
169-
| 3 | `Discount` - percentage logic | Stateless, predictable, complements pricing |
170-
| 4 | `ShoppingCart` - add/remove items | Start using composition of domain elements |
171-
| 5 | `ShoppingCart` - apply discount | Introduces first mutation to cart state |
172-
| 6 | `ShoppingCart` - total price & print | Drives end-to-end expectation-based testing |
173-
| 7 | `ProductCatalogue` or Registry | Encapsulate product lookup and validation |
168+
| Iteration | Focus | Why Start Here? |
169+
| --------- | ---------------------------------------- | ------------------------------------------------------------ |
170+
| 1 | `Product` - price per unit and VAT logic | Small, atomic, pure — perfect TDD start |
171+
| 2 | `CartItem` - quantity & total price | Introduces aggregation, still isolated logic |
172+
| 3 | `Discount` - percentage logic | Stateless, predictable, complements pricing |
173+
| 4 | `ShoppingCart` - add items | Start using composition of domain elements |
174+
| 5 | `ShoppingCart` - apply discount | Introduces first mutation to cart state |
175+
| 6 | `ShoppingCart` - total price & print | Drives end-to-end expectation-based testing |
176+
| 7 | `ProductCatalogue` or Registry | Encapsulate product lookup and validation |
177+
| 8 | `ShoppingCart` - delete items | TODO - Drive removing Items from the cart |
178+
| 9 | `ShoppingCart` - updateItemQuantity | TODO - Drive changing the quantity |
179+
| 10 | `ShoppingCart` - getItems | TODO - Drive getting the items to be more inline with a cart |
174180

175181
### Evolution Flow Summary
176182

@@ -191,7 +197,7 @@ export interface ShoppingCart {
191197
- `print()` or `toString()` as test-driving format rendering
192198
- Possibly inject or access product catalogue here
193199

194-
### When to Consider *Outside-In*
200+
### When to Consider _Outside-In_
195201

196202
You could start Outside-In **only** if:
197203

@@ -202,4 +208,4 @@ But in this kata, that’s harder to justify because the logic in the "leaf" typ
202208

203209
### Summary
204210

205-
Thnanks Emmanuael Valverde, for your cool takle on this [kata](https://www.codurance.com/katas/shopping-cart-kata). There were a few sneaky catches with the pricing. I have done this kata before using simple types and I found myself producing more code this time. I also did outside in, before, mocking and faking bits until I had the final design. I think breaking this up into the seperate phases made it easier to get my head around each concept, so I am glad I did it this way. The thing didn't like is it forced me into a solution by virtue of what I simplified. It may be a good or bad thing, no idea.
211+
Thanks Emmanuael Valverde, for your cool take on this [kata](https://www.codurance.com/katas/shopping-cart-kata). There were a few sneaky catches with the pricing. I have done this kata before using simple types and I found myself producing more code this time. I also did outside in, before, mocking and faking bits until I had the final design. I think breaking this up into the seperate phases made it easier to get my head around each concept, so I am glad I did it this way. The thing didn't like is it forced me into a solution by virtue of what I simplified. It may be a good or bad thing, no idea.

0 commit comments

Comments
 (0)