Code Kata




Giordano Scalzo
Who is a programmer?
A step towards management...
...or point of no return!
NO!
Classical Ages of Computer Programming
Dark Ages of Computer Programming
Renaissance of Computer Programming
A real profession
The Way of the carpenter is to become
proficient in the use of his tools,
first to lay his plans with a true measure and
then perform his work according to plan.

                -Go Rin No Sho
SW Craftsman Tools: Languages
SW Craftsman Tools: Tdd



Test-driven development (TDD) is a
software development technique that relies
on the repetition of a very short development
cycle




                                     http://en.wikipedia.org/wiki/Test-driven_development
Tdd




first the developer writes a failing automated
test case that defines a desired improvement
or new function




                                 http://en.wikipedia.org/wiki/Test-driven_development
Tdd




then produces code to pass that test




                            http://en.wikipedia.org/wiki/Test-driven_development
Tdd




and finally refactors the new code to
acceptable standard




                            http://en.wikipedia.org/wiki/Test-driven_development
Tdd cycle
Tdd cycle
Tdd cycle
Tdd cycle
Tdd cycle
Tdd cycle
Tdd cycle
Tdd cycle
Tdd cycle
Tdd cycle
Tdd cycle




Got it!
Tdd cycle




Easy, isn’t it?
Tdd cycle




No, at all! :-(
SW Craftsman Tools: Split stories




     Business problem
SW Craftsman Tools: Split stories




        Presentation


       Business logic


        Persistence
SW Craftsman Tools: Split stories

     Ft1    Ft2         Ftn

        Presentation


       Business logic


        Persistence
SW Craftsman Tools: Editors
When improve
   them?
Work != Practice
Code kata
Code kata




Kata (    or    literally: "form") is a Japanese
word describing detailed choreographed
patterns of movements practised either solo
or in pairs.
Code kata




Practice on small exercise
Code kata




30 minutes to an hour long
Code kata styles


‘Prag’ Dave Thomas
Simple Problems
Many correct solutions
Different each time
Learn by experimentation
Code kata styles


‘Uncle’ Bob Martin
Copy a Master
Follow forms precisely
Learn by Repetition
Aim for perfect performance
Performance!
Kata 9: Back to Checkout
 http://codekata.pragprog.com/2007/01/kata_nine_back_.html




    Item   Unit      Special
           Price     Price
    --------------------------
      A     50       3 for 130
      B     30       2 for 45
      C     20
      D     15
total with no special offers

it "is zero when nothing is scanned"
it "is 50 when A is scanned"
it "is 80 when AB is scanned"
it "is 115 when CDBA is scanned"
total when A is on special offer

   it "is 130 when AAA is scanned"
   it "is 180 when AAAA is scanned"
   it "is 260 when AAAAAA is scanned"
total when A and B are both in
special offer

  it "is 175 when AAABB is scanned"
Resources
http://codekata.pragprog.com
http://codingkata.org
http://www.katacasts.org
http://www.coderloop.com
http://www.vimgolf.com
Randori
Code Retreat
It’s your turn!
giordano.scalzo@cleancode.it
@giordanoscalzo
www.slideshare.net/giordano
github.com/gscalzo

Code kata