2. Lean Code
Objective: Acquiring and improve coding skills
by Chris Parsons (@chrismdp)
Javier Gamarra (@nhpatt) - http://nhpatt.com/slides/a%20LEAN-CODE%20experience/
#slide2
7. Iteration 0
10 minutes to choose a pair and setup the
development environment
Write a terminal application, accepts an input and
print the result in the screen
9. Iteration 1
10 minutes to write an easy cash register
Acceptance Test
• 'apple' cost 1€, 'banana' cost
1.5€ and 'cherry' cost 0,75€
• we should accept this words for
every input line (stdin)
• Print de total in cents in the
stdout every time
• apple -> 100
• cherry -> 175
• cherry -> 250
10. Iteration 2
10 minutes to add a discount
Acceptance Test
• Same inputs as before
• After two cherries you
will save 20 cents
• apple -> 100
• cherry -> 175
• cherry -> 230
11. Iteration 3
10 minutes to allow to read CSV format
Acceptance Test
• Accept values separed
by commas
• Same prices as
Iteration 2
• apple, cherry,
banana -> 325
• cherry, cherry -> 130
12. Iteration 3a
Stop! New urgent requirements. Same delivery date
Acceptance Test
• KWIK-E-MART shops have been notified to a
delay in the CSV format feature
• The input format is again one product per line
• Cherries have a 30 cents discount
• Bananas have the discount: 'buy two and one is
free'
• cherry -> 75
• cherry -> 120
• banana -> 270
• banana -> 270
13. Iteration 4
10 minutes to add location
Acceptance Test
• KWIK-E-MART shops stills notified regarding
the delay in the CSV format feature
• Cherrys discount is again 20 cents
• We should allow 'manzana' and 'apfel' for
apples
• cherry -> 75
• manzana -> 175
• cherry -> 230
• banana -> 380
• banana -> 380
• apple -> 480
14. Iteration 5
10 minutes to add discounts by name
Acceptance Test
• CSV format feature should be
delivered in the next sprint
• 3 x manzana: we will discount 1€
• 2 x apfel: we will discount 0.5€
• apfel -> 100
• manzana -> 200
• manzana -> 300
• apple -> 400
• manzana -> 400
• apfel -> 450
• cherry -> 525
• cherry -> 580
15. Iteration 5a
10 minutes to add descounts by name
Acceptance Test
• NEW CHANGE!
• 3 x manzana: we will
discount 1€
• 2 x apfel: we will discount 1€
• apfel -> 100
• manzana -> 200
• manzana -> 300
• apple -> 400
• manzana -> 400
• apfel -> 400
• cherry -> 475
• cherry -> 530
• banana -> 680
16. Iteration 6
10 minutes to deliver CSV format and allow super-discounts
Acceptance Test
• Allow to use inline and CSV input
format
• 2 x apfel: we will discount 1.5€
• By 4 apples and save another euro
• By 5 fruits and save 2 euros
• apfel, manzana,
manzana, apfel -> 250
• banana -> 200
• apfel, manzana,
manzana, apple,
apfel -> 150
18. • Remove waste: just do what is requested not anymore
trying to predict the future. YAGNI+KISS
• Focus on deliver maximum value: focus on customer
needs and on tasks with the most impact on business
• Deliver quickly: release fast, ask frequently for
feedback and show real work in progress. Time To
Market
• Take decisions as later as possible: but for the few
ones to take try to do it consistent and flexible: open to
changes and refactor, for the rest just use emerging
design + SOLID
Lean Code
19. • Gojko Adzic - http://gojko.net/2011/05/26/sc2011-lean-code-
solution-in-awk/
• Chris Parsons - https://github.com/chrismdp/checkout-kata
• Javier Gamarra - https://github.com/nhpatt/Checkout
Solutions