milano legacy coderetreat 2013

35
Legacy Coderetreat Milano 2013 Text 10 PRINT "Hello World" 20 Go to 10

Upload: gabriele-lana

Post on 10-May-2015

928 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: Milano Legacy Coderetreat 2013

LegacyCoderetreatMilano 2013

Text

10 PRINT "Hello World"20 Go to 10

Page 2: Milano Legacy Coderetreat 2013
Page 3: Milano Legacy Coderetreat 2013
Page 4: Milano Legacy Coderetreat 2013
Page 5: Milano Legacy Coderetreat 2013
Page 6: Milano Legacy Coderetreat 2013

#lcrm13

Page 7: Milano Legacy Coderetreat 2013

Format of the Day

from 10:00 to 13:00

MORNING

from 13:00 to 14:00

LUNCH

from 14:00 to 17:00

AFTERNOON

Page 8: Milano Legacy Coderetreat 2013

45 min coding10 min retrospective5 min break

Format of the Day

45’ coding10’ review5’ break

Page 9: Milano Legacy Coderetreat 2013
Page 10: Milano Legacy Coderetreat 2013

•CHALLENGE•REPEAT•FEEDBACK

DEEPPRACTICE

Page 11: Milano Legacy Coderetreat 2013

NO PRESSURE

feel free toexperiment

Page 12: Milano Legacy Coderetreat 2013

NO PRESSUREdo not completethe task but master it

Page 13: Milano Legacy Coderetreat 2013

Practice

Page 14: Milano Legacy Coderetreat 2013

Refactoring

•AUTOMATIC•MANUAL

Page 15: Milano Legacy Coderetreat 2013

Read Code

Page 16: Milano Legacy Coderetreat 2013

TestCode

CharacterizeBehaviour

Page 17: Milano Legacy Coderetreat 2013

Design

•BY CODE•BY TESTS•BY SMELLS

Page 18: Milano Legacy Coderetreat 2013

Rules

Page 19: Milano Legacy Coderetreat 2013

When youdon’tpair...

Page 20: Milano Legacy Coderetreat 2013

aftereach

session

Pair

Page 21: Milano Legacy Coderetreat 2013

DELETEYOURCODEAFTEREACHSESSION

Page 22: Milano Legacy Coderetreat 2013

Playbook

Page 23: Milano Legacy Coderetreat 2013

Golden Master(aka characterization tests)

session #1

Page 24: Milano Legacy Coderetreat 2013

# suppose that our legacy code is this program called ‘game’$ game > GOLDEN_MASTER

# after some changes we can check to see if behaviour has changed$ game > OUT-01$ diff GOLDEN_MASTER OUT-01

# after some other changes we check again and...$ game > OUT-02$ diff GOLDEN_MASTER OUT-02

# GOLDEN_MASTER and OUT-01 are the same

# GOLDEN_MASTER and OUT-02 are different -> behaviour changed

Golden Master(aka characterization tests)

Page 25: Milano Legacy Coderetreat 2013

# what about something with a random output?$ whatthecommit> I think I fixed a bug :-)> for great justice.> syntax> LOL!> ...

# somewhere in the code...$ cat whatthecommit | ack -i ‘rand’> 5: g = Random.new> 42: messages[g.rand(NUMBER_OF_MESSAGES)]

Golden Master(aka characterization tests)

Page 26: Milano Legacy Coderetreat 2013

# sequence generators are initialized with a seed# two random sequence generators initialized with the same# seed are going to produce the same sequence of numbers

$ irb1.9.3 > g = Random.new1.9.3 > (1..10).map{g.rand(1000)} => [691, 362, 997, 692, 236, 532, 687, 616, 218, 702]1.9.3 > g = Random.new 1.9.3 > (1..10).map{g.rand(1000)} => [865, 186, 89, 382, 894, 708, 769, 850, 452, 85] 1.9.3 > g = Random.new(1)1.9.3 > (1..10).map{g.rand(1000)} => [37, 235, 908, 72, 767, 905, 715, 645, 847, 960] 1.9.3 > g = Random.new(1)1.9.3 > (1..10).map{g.rand(1000)} => [37, 235, 908, 72, 767, 905, 715, 645, 847, 960]

Golden Master(aka characterization tests)

Page 27: Milano Legacy Coderetreat 2013

# we need to change the code to take somehow the seed $ whatthecommit --seed=42> fix the bug, for realz> to those I leave behind, good luck!> herping the derp> changes> ...

# so that with the same seed, the same code is going to# create the same output$ whatthecommit --seed=42> fix the bug, for realz> to those I leave behind, good luck!> herping the derp> changes> ...

Golden Master(aka characterization tests)

Page 28: Milano Legacy Coderetreat 2013

$ git clone https://github.com/gabrielelana/trivia.git$ cd triva# enjoy

Page 29: Milano Legacy Coderetreat 2013

session #1Characterize the behaviour of the code with the golden master technique

Test Code

Page 30: Milano Legacy Coderetreat 2013

# to get the already done golden master$ git merge golden-master

Page 31: Milano Legacy Coderetreat 2013

session #2

Refactoring & Design

Refactor the code so that it will be easy to create a newcategory of questions

Page 32: Milano Legacy Coderetreat 2013

session #3

Test Code

Put undertest therollmethod/function

Page 33: Milano Legacy Coderetreat 2013

session #4

Read Code

Mark all the smells in the code. Remove at least 3 of them

Page 34: Milano Legacy Coderetreat 2013

session #5

Remove all the duplication

Page 35: Milano Legacy Coderetreat 2013

session #6Replacing the penalty rules should be a one line change!