Xstream 

Coding 

Dojo #2



Warsaw, 29.11.2013

What is Dojo?

"Place of learning the way"


Coding Dojo

a  place to learn and have fun while programming safe place to practice and learn by making mistakes

Short history

2004 - Paris, France

  • No habit of improving skills outside of work environment
  • Code used to learn new tech goes to production
  • No tests for new technologies
  • Develop always using same skillset

Types of Coding Dojo

  1. Prepared Kata
    • A presenter shows how to solve the challenge from scratch, using TDD and BabySteps. 
    •  Each step must make sense to everyone present for. 
    •  People should interrupt only if they don't understand what is going on.

  2. Randori Kata
    • The challenge is solved by the coding pair (driver and copilot). 
    • Everyone present is invited to help. 
    •  Each pair has a small (5 or 7 minutes) timebox to advance, using TDD and BabySteps. 
    •  At the end of the timebox, the driver goes back to the audience, the copilot becomes driver and one of the audience step up to be copilot.

Objectives

  • Learn by practicing,
  • Fail in safe environment,
  • Teach one another,
  • Explain yourself to peers,
  • Explore each other's solutions,
  • Have fun!

Rules

  1. Simple design, baby steps,
  2. Unit tests are required,
  3. Switch in front of keyboard,
  4. Focus!

BabySteps

  • Write unit test for Particular BabyStep 
  •  Run it, it should fail 
  •  If it is not failing - review the test it might be wrong 
  •  Written test should generate interfaces 
  •  Write an implementation until the test is green 
  •  Go to the next BabyStep

Format

  • Divide into groups,
  • Present problem to be solved,
  • Work on given task,
  • Demo of each solution.

Time to split

Problem

Assumptions:

  1. There are 5 books in same series,
  2. Each book costs 8 EUR,
  3. With each different book you get 5% discount.

Example:
Buying 4 books of which 3 are unique you get 15% discount for these books and no discount for 4th book.

Problem - TaSK

Write a piece of code to calculate price of any possible shopping basket giving as big discount as possible.

Problem - advanced example

  • 2 copies of 1st book,
  • 2 copies of 2nd book,
  • 2 copies of 3rd book,
  • 1 copy of 4th book,
  • 1 copy of 5th book,
  • Total amount?
  • 5 * 8 * 0.75 + 3 * 8 * 0.9 = 51.60
  • 4 * 8 * 0.8 + 4 * 8 * 0.8 = 51.20

Questions?

Xstream Coding Dojo #2

By Paweł Lewtak

Xstream Coding Dojo #2

  • 569