Day of code
-
Upload
nigel-runnels-moss -
Category
Technology
-
view
248 -
download
0
description
Transcript of Day of code
Day of Code
@sleepyfox for craft
@sleepyfox
London Code Dojo:Introductions
• Put down your croissant (just for the moment)
• Say the three things:• Your name• What you do (@work that is)• A random factoid e.g. my mother was
a Welsh sheep-farmer
@sleepyfox
What does it mean?
Dojo means: ‘Place of learning the
Way’
@sleepyfox
What does it mean?
Kata means ‘way of doing’A form or choreographed series of motions designed to teach a particular skill or pattern
@sleepyfox
Kata?
@sleepyfox
Deliberate Practice
• Gladwell1 et. al. 10 yrs or 10,000 hrs practice to achieve expert performance
• But practice must: • be focussed• be goal-directed• stretch your abilities• give continuous feedback• be followed by self-reflection
@sleepyfox
Dojo Kun
• We respect each others’ commitment• Please no phones, email, Facebook...
• We all do TDD• We all do Pair Programming• We swap partners each cycle• We follow the rules of ‘Simple Design’
@sleepyfox
Simple Design
Simple Design is code that:1. Passes all the tests2. Is clear, expressive and consistent3. Duplicates no behaviour or
configuration4. Minimises the number of classes and
methods and modules
@sleepyfox
Format
• People pair up• We present the problem to be solved• Each cycle is a pomodoro (25 mins)
• http://tomatoi.st/codedojo• When time is up: 5 min break to demo
your code to nearby team and reflect• Every 2 pomodoros we delete code (but
may keep tests), rinse and repeat...
@sleepyfox
Kata:
@sleepyfox
Overload
• Two players: white and black• White player goes first, play alternates• Pieces are the same colour as player • Must place your piece on either:
• An empty square• A square with one of your pieces on• Cannot place on other player's piece
@sleepyfox
Overload 2
• If a square is overloaded, pieces 'explode' into adjacent squares
• If they land on an opponent's piece they are all turned to player's colour!
• A square's overload limit is:• Corner: 2• Side: 3• Middle: 4
@sleepyfox
Overload 3
• To win: turn all pieces to your colour• (Obviously 1st turn is an exception!)• You have 2 Pomodoros (1 hour)
@sleepyfox
Begin!
Hajime!
@sleepyfox
Stop!
Yame!
@sleepyfox
5 minute break
• Stop typing!
• Now!
• 5 mins to show code and reflect
• Delete code
• (may keep tests)
@sleepyfox
Object Calisthenics 1
• SRP: Single Responsibility Principle • No method more than 5 lines or one
indentation level• No method can have more than 2
arguments
@sleepyfox
Begin!
Hajime!
@sleepyfox
Stop!
Yame!
@sleepyfox
Yame! (stop)
• Stop typing!
• Now!
• 5 mins to show code and reflect
• Delete code
• (may keep tests)
@sleepyfox
Lunch
@sleepyfox
Object Calisthenics 2
• To work off some of those calories:• Wrap all Primitives• This includes ints, floats, strings etc.
@sleepyfox
Begin!
Hajime!
@sleepyfox
Stop!
Yame!
@sleepyfox
Yame! (stop)
• Stop typing!
• Now!
• 5 mins to show code and reflect
• Delete code
• (may keep tests)
@sleepyfox
Object Calisthenics 3
Law of Demeter:• Each unit should have only limited
knowledge about other units: only units "closely" related to the current unit
• Each unit should only talk to its friends; don't talk to strangers
• Only talk to your immediate friends
@sleepyfox
Demeter in OO Land
• if m is a method of O, m can invoke only:• other methods of O• m's parameters• Any objects created within m• O's direct object components• A global, accessible by O, in scope of m
• 'Only one dot' - dog.walk() good, • dog.leg.walk() bad
@sleepyfox
Begin!
Hajime!
@sleepyfox
Stop!
Yame!
@sleepyfox
Yame! (stop)
• Stop typing!
• Now!
• 5 mins to show code and reflect
• Delete code
• (may keep tests)
@sleepyfox
Object Calisthenics 4
• First class collections - if a class has a collection in it then it may have no other attributes
• All classes must have state - no utilities• No getters, setters, properties:
"Tell, don't ask!"
@sleepyfox
Begin!
Hajime!
@sleepyfox
Stop!
Yame!
@sleepyfox
Yame! (stop)
• Stop typing!
• Now!
• Don't delete code or tests
@sleepyfox
Reflection
Thank you@sleepyfox on Twitter
meetup.com/London-Code-Dojo
creativecommons.org/licenses/by-nc-nd/3.0