Code Katas
        Practicing Your Craft
           Mike Clement
           @mdclement
  mike@softwareontheside.com
http://blog.softwareontheside.com
“Often the true value
  of a thing isn’t the
thing itself, but instead
   is the activity that
       created it.”
                  -Dave Thomas
Chad Fowler on Practice
“As a musician, I might spend a significant portion
of my practice schedule playing things that nobody
would want to listen to…. I would certainly never
record them and release them on a CD. I wouldn’t
even bore anyone with these sounds unless they
either lived in my house and had no choice or were
being paid to listen to them and offer suggestions
for improvement. This is an example of “work” in
which the action is far more valuable than the
direct output.”
           http://chadfowler.com/2003/03/25/valueless-software
The Lie

BUT I “PRACTICE” ON THE JOB!
Dave Thomas on Practice
“It’s like taking a group of fit kids and telling
them that they have four quarters to beat the
Redskins (hey, we manage by objectives, right?).
In software we do our practicing on the job, and
that’s why we make mistakes on the job. We
need to find ways of splitting the practice from
the profession. We need practice sessions.”
         http://codekata.pragprog.com/2007/01/code_kata_backg.html
Dave Thomas’s Keys to Practice

•Pressure Off
•Learn how to play with
 code Fundamentally
  incompatible with “on
        the job”!
       http://www.codekata.com/2007/01/code_katahow_it.html
Quantity or Quality?

CERAMICS
Shu Ha Ri
• 守 Shu – House of Laws; to abide
  by, to defend
• 破 Ha – Stone; to break
• 離 Ri – Bird; to leave, to depart
• Similar to Dryfus model
   – Novice, Advanced Beginner, Competent, Proficient, Expert
• Similar to Apprentice model
   – Apprentice, Craftsman, Master
The rush past 守 (Shu)

I’M SO SMART
So what are
   katas?
Code Katas are Shu




Slow down!
Other forms of practice

KATAS AREN’T THE ONE TRUE
PRACTICE?
Solo Randori?
•   Often referred to as “Katas”
•   Outline a problem, but don’t outline solution
•   More of a way to discover different paths
•   破 Ha
•   Can lead to new Katas
Group Randori
• Free-style practice                     • Pair Programming
• “chaos taking” or “grasping             • Use TDD
  freedom”                                • Start from scratch
• Contrast with Katas                     • Everyone should be
• “defends against multiple                 following
  attackers in quick                      • Pair should be explaining
  succession without knowing              • Audience gives suggestions
  how they will attack or in                only with when Green
  what order”
                                          • Example at
                                            http://vimeo.com/2499540

                                                   http://codingdojo.org/cgi-
   http://en.wikipedia.org/wiki/Randori              bin/wiki.pl?RandoriKata
Koans
• Koans are questions without absolute answers
  which are used to break down assumptions
  and reveal underlying truths
• http://rubykoans.com/
Code Retreat
• Problem: Conway's Game of Life
• Length of Session: 45 minutes
• Duration: 8.30am to 5 or 6pm
• Pair-programming is necessary, as the knowledge transfer
  contained in that activity is essential to the practice
• Prefer using Test-Driven Development (TDD)
• After each session, pairs should be swapped
• After each session, code must be deleted, not put in a
  branch, not stashed, just deleted with no trace left

                              http://coderetreat.com/facilitation.html
Guided or Prepared Kata

LET’S TRY IT OUT
“Often the true value
  of a thing isn’t the
thing itself, but instead
   is the activity that
       created it.”
                  -Dave Thomas
Kata Lists
• http://codingdojo.org/cgi-
  bin/wiki.pl?KataCatalogue
• http://codekata.pragprog.com/2007/01/code
  _kata_backg.html
• http://stackoverflow.com/questions/44533/yo
  ur-favorite-code-kata
• http://www.katacasts.com/
• http://katas.softwarecraftsmanship.org/
Action Items!
• Repeat this kata at least once a day for a week or
  two. Memorize and perfect it!
• Find other Katas that are useful to you
• Share Katas with your friends and co-workers
   – Lead a guided Kata session at work
• Explore other forms of practice
   – Come to my Randori session after lunch (1:30pm)
• Attend the Utah Software Craftsmanship Group!
• Practice, Practice, Practice!
Me
•   @mdclement
•   mike@softwareontheside.com
•   http://blog.softwareontheside.com
•   Utah Software Craftsmanship Group
    – https://groups.google.com/forum/#!forum/ut-
      software-craftsmanship
    – @utahsc
    – First Wednesday, Neumont, Room 300

Code Katas Spring 2012

  • 1.
    Code Katas Practicing Your Craft Mike Clement @mdclement mike@softwareontheside.com http://blog.softwareontheside.com
  • 2.
    “Often the truevalue of a thing isn’t the thing itself, but instead is the activity that created it.” -Dave Thomas
  • 3.
    Chad Fowler onPractice “As a musician, I might spend a significant portion of my practice schedule playing things that nobody would want to listen to…. I would certainly never record them and release them on a CD. I wouldn’t even bore anyone with these sounds unless they either lived in my house and had no choice or were being paid to listen to them and offer suggestions for improvement. This is an example of “work” in which the action is far more valuable than the direct output.” http://chadfowler.com/2003/03/25/valueless-software
  • 5.
    The Lie BUT I“PRACTICE” ON THE JOB!
  • 6.
    Dave Thomas onPractice “It’s like taking a group of fit kids and telling them that they have four quarters to beat the Redskins (hey, we manage by objectives, right?). In software we do our practicing on the job, and that’s why we make mistakes on the job. We need to find ways of splitting the practice from the profession. We need practice sessions.” http://codekata.pragprog.com/2007/01/code_kata_backg.html
  • 7.
    Dave Thomas’s Keysto Practice •Pressure Off •Learn how to play with code Fundamentally incompatible with “on the job”! http://www.codekata.com/2007/01/code_katahow_it.html
  • 8.
  • 9.
    Shu Ha Ri •守 Shu – House of Laws; to abide by, to defend • 破 Ha – Stone; to break • 離 Ri – Bird; to leave, to depart • Similar to Dryfus model – Novice, Advanced Beginner, Competent, Proficient, Expert • Similar to Apprentice model – Apprentice, Craftsman, Master
  • 10.
    The rush past守 (Shu) I’M SO SMART
  • 11.
  • 12.
    Code Katas areShu Slow down!
  • 13.
    Other forms ofpractice KATAS AREN’T THE ONE TRUE PRACTICE?
  • 14.
    Solo Randori? • Often referred to as “Katas” • Outline a problem, but don’t outline solution • More of a way to discover different paths • 破 Ha • Can lead to new Katas
  • 15.
    Group Randori • Free-stylepractice • Pair Programming • “chaos taking” or “grasping • Use TDD freedom” • Start from scratch • Contrast with Katas • Everyone should be • “defends against multiple following attackers in quick • Pair should be explaining succession without knowing • Audience gives suggestions how they will attack or in only with when Green what order” • Example at http://vimeo.com/2499540 http://codingdojo.org/cgi- http://en.wikipedia.org/wiki/Randori bin/wiki.pl?RandoriKata
  • 16.
    Koans • Koans arequestions without absolute answers which are used to break down assumptions and reveal underlying truths • http://rubykoans.com/
  • 17.
    Code Retreat • Problem:Conway's Game of Life • Length of Session: 45 minutes • Duration: 8.30am to 5 or 6pm • Pair-programming is necessary, as the knowledge transfer contained in that activity is essential to the practice • Prefer using Test-Driven Development (TDD) • After each session, pairs should be swapped • After each session, code must be deleted, not put in a branch, not stashed, just deleted with no trace left http://coderetreat.com/facilitation.html
  • 18.
    Guided or PreparedKata LET’S TRY IT OUT
  • 19.
    “Often the truevalue of a thing isn’t the thing itself, but instead is the activity that created it.” -Dave Thomas
  • 20.
    Kata Lists • http://codingdojo.org/cgi- bin/wiki.pl?KataCatalogue • http://codekata.pragprog.com/2007/01/code _kata_backg.html • http://stackoverflow.com/questions/44533/yo ur-favorite-code-kata • http://www.katacasts.com/ • http://katas.softwarecraftsmanship.org/
  • 21.
    Action Items! • Repeatthis kata at least once a day for a week or two. Memorize and perfect it! • Find other Katas that are useful to you • Share Katas with your friends and co-workers – Lead a guided Kata session at work • Explore other forms of practice – Come to my Randori session after lunch (1:30pm) • Attend the Utah Software Craftsmanship Group! • Practice, Practice, Practice!
  • 22.
    Me • @mdclement • mike@softwareontheside.com • http://blog.softwareontheside.com • Utah Software Craftsmanship Group – https://groups.google.com/forum/#!forum/ut- software-craftsmanship – @utahsc – First Wednesday, Neumont, Room 300

Editor's Notes

  • #3 Verbs vs. NounsRequirements“Plans are useless, but planning is invaluable” – Dwight D. Eisenhowerthe value is the process that everyone goes through in order to produce the document: the understanding gained, the relationships forged, the negotiations, the compromises, and all the other little interactions which share information.QualityPlan, measure, build a quality product!Quality is PART OF THE PROCESS. Quality is in the spirit of the smallest of our daily activities.
  • #4 Read quote
  • #5 Who plays a musical instrument? Practice time vs. performance time?ScalesArpeggiosExtended tones (wind instruments)Various technical patternsLast bars of Franz Liszt's Transcendental Étude No. 2: one of the most difficult of Liszt's études, this is a study in passages for alternating and overlapping hands.Sports is the same way, how much time is spent practicing versus performing?
  • #6 Clearly each of you is here at Code Camp on a Saturday because you KNOW that you can’t get everything you need for your profession, to be a master of your craft by practicing “on the job”.
  • #8 Provide a temporal oasis where it’s OK not to worry about some approaching deadline.Learn how to play with code: how to make mistakes, how to improvise, how to reflect, and how to measure. This is hard: we’re trained to try to do things right rather than improvise.These “keys” are fundamentally incompatible with “on the job” learning.One the job has deadlines and restrictions. It’s very visible to other people so mistakes are less tolerated.Sure there is a component to this. We can learn on the job. “Live” experience is important. For example with public speaking, you can practice and practice, but actually presenting is different. Practicing helps, but it doesn’t replace real experience.SportsMusicMilitary combatCooking for your in-laws
  • #9 The ceramics teacher announced on opening day that he was dividing the class into two groups. All those on the left side of the studio, he said, would be graded solely on the quantity of work they produced, all those on the right solely on its quality. His procedure was simple: on the final day of class he would bring in his bathroom scales and weigh the work of the "quantity" group: fifty pound of pots rated an "A", forty pounds a "B", and so on. Those being graded on "quality", however, needed to produce only one pot - albeit a perfect one - to get an "A".Well, came grading time and a curious fact emerged: the works of highest quality were all produced by the group being graded for quantity. It seems that while the "quantity" group was busily churning out piles of work - and learning from their mistakes - the "quality" group had sat theorizing about perfection, and in the end had little more to show for their efforts than grandiose theories and a pile of dead clay.http://www.codinghorror.com/blog/2008/08/quantity-always-trumps-quality.htmlArt & Fear: Observations On the Perils (and Rewards) of Artmaking [Paperback]David Bayles (Author), Ted Orland (Author)We learn by DOING!I would argue that we can’t do quantity on the job. We have to get the volume of repetitions elsewhere.
  • #10 Concept introduced to software by Alistair CockburnShu - the technical foundation of the artSingle instructorCopy techniques without modificationit is the instructor that decides when the student moves on from Shu to Ha, not the studentIt’s up to the student to follow the instructor’s teaching as an empty vessel to be filled upHareflect on the meaning and purpose of everything that s/he has learned and thus come to a deeper understanding of the artRimust think originally and develop from background knowledge original thoughts about the art and test them against the reality of his or her background knowledge and conclusions as well as the demands of everyday lifethe art truly becomes the practitioner’s own and to some extent his or her own creationInvent own techniques
  • #11 Everyone is at different levels with different skills that they are developing, but nobody is master of all skills.We often jump right into critiquing a method or idea instead of attempting it “as is” first. We think that we’re so smart that we can skip past the “beginner” stuff and get right into it.Programmers are especially susceptible to this as we have sizable egos generally.Seek first to understand.
  • #12 Japanese word describing detailed choreographed patterns of movements practiced either solo or in pairs.A kata is a coding exercise that performed repeatedly and perfected.Framework for focused practiceTDD/Unit TestsPerformanceStructureMemory UseTool use (IDE, text editor)Practice comes to an end; with a real problem… not so muchPath is laid out for you so there is a definite end
  • #13 Slow down!Practice the feel and to internalize the movesBuilding muscle memoryChange your intuitionTrain your eyes and fingers to recognize and respond to patternsValue in repetition even if you don’t agree.You may not like what the kata is teaching you, but that is learning too.
  • #16 Can be one session of a “day of randori”
  • #18 Anybody attended one of these?Working to have one in Utah.
  • #19 As we learned earlier, the best way to learn is by experimenting and repeating so that’s what we’re going to do
  • #20 Remember that the problem that we solved today is not really that important. It’s not important that we have a piece of code to score a bowling game. It is important that we go through the exercise and take from it what we can.