25
Code retreat www.mozaicworks.com

Coderetreat @AgileFinland Helsinki 2014 11 13

Embed Size (px)

Citation preview

Page 1: Coderetreat @AgileFinland Helsinki 2014 11 13

Code retreat

www.mozaicworks.com

Page 2: Coderetreat @AgileFinland Helsinki 2014 11 13

www.mozaicworks.com

Me

Adi BolboacaOrganizational & Technical

Trainer & Coach

Page 3: Coderetreat @AgileFinland Helsinki 2014 11 13

2009, First time outside US

Page 4: Coderetreat @AgileFinland Helsinki 2014 11 13

Why?

Learn through pairingExtend your comfort zone

PracticeExperiment

Learn new practices

www.mozaicworks.com

Page 5: Coderetreat @AgileFinland Helsinki 2014 11 13

How?

1 day of codingChoose a simple problem

6 pairing partnersOn average 135 minutes of coding

6 different constraintsA lot of fun!

www.mozaicworks.com

Page 6: Coderetreat @AgileFinland Helsinki 2014 11 13

How it started

CodeMash conference 2009

Gary BernhardtPatrick Welsh

Nayan HajratwalaCorey Haines

www.mozaicworks.com

Page 7: Coderetreat @AgileFinland Helsinki 2014 11 13

How it started

RepeatableDay-long

Practice the fundamentals of programmingIntense day of coding

www.mozaicworks.com

Page 8: Coderetreat @AgileFinland Helsinki 2014 11 13

Day structure

15' introduction3 sessions of 45' coding + 15' retro&break

1h lunch3 sessions of 45' coding + 15' retro&break

15' closing circle

www.mozaicworks.com

Page 9: Coderetreat @AgileFinland Helsinki 2014 11 13

Principles

Language agnosticDo not try to finish the problem

Delete the code after each sessionFocus on practicing

Experiment each sessionHave fun!

www.mozaicworks.com

Page 10: Coderetreat @AgileFinland Helsinki 2014 11 13

How to take advantage1. Embrace the freedom of deleting the code

2. Do what you always wanted but couldn't

3. Get out of your comfort zone

4. Pair with strangers in languages you don't know

5. What you learn is your responsibility

Page 11: Coderetreat @AgileFinland Helsinki 2014 11 13

Prerequisites

ComputerCoding environmentTesting framework

Source control (git, svn, etc)

www.mozaicworks.com

Page 12: Coderetreat @AgileFinland Helsinki 2014 11 13

The four elements of simple design

1) Passes its tests2) Minimizes duplication

3) Maximizes clarity4) Has fewer elements

www.mozaicworks.com

Page 13: Coderetreat @AgileFinland Helsinki 2014 11 13

Conway's game of life

Having an infinite 2D orthogonal universeBeing given an initial generation called a seedThe following rules are applied simultaneously

A live cell having less than 2 live neighbors diesA live cell having 2 or 3 live neighbors lives A live cell having more than 3 neighbors diesA dead cell having 3 neighbors becomes alive

www.mozaicworks.com

Page 14: Coderetreat @AgileFinland Helsinki 2014 11 13

Session 1: Understand the problem

Find a pairChoose a programming language

Setup the environmentChoose an entry point for the problem

Start in 5 min

www.mozaicworks.com

Page 15: Coderetreat @AgileFinland Helsinki 2014 11 13

Conway's game of life

Having an infinite 2D orthogonal universeBeing given an initial generation called a seedThe following rules are applied simultaneously

A live cell having less than 2 live neighbors diesA live cell having 2 or 3 live neighbors lives A live cell having more than 3 neighbors diesA dead cell having 3 neighbors becomes alive

www.mozaicworks.com

Page 16: Coderetreat @AgileFinland Helsinki 2014 11 13

Session 2: Full test coverage

100% test coverage during the session

When test is below 100% the facilitator stops you from adding functionalities until the coverage is

back at 100%

All your tests must contain the assert

Install a code coverage tool for your languagewww.mozaicworks.com

Page 17: Coderetreat @AgileFinland Helsinki 2014 11 13

Session 3: Object calisthenics

ConceptsUse only one level of indentation per method

Don’t use the else keywordWrap all primitives and strings

Use only one dot per lineDon’t abbreviate

Keep all entities smallDon’t use any classes with more than two instance

variablesUse first-class collections

Don’t use any getters / setters / propertieswww.mozaicworks.com

Page 18: Coderetreat @AgileFinland Helsinki 2014 11 13

Code retreat

1 hour Lunch

www.mozaicworks.com

Page 19: Coderetreat @AgileFinland Helsinki 2014 11 13

Session 4: Taking Baby Steps1) Initialize source control repository2) Start a timer for 2 minutes3) Write exactly one testa) Timer rings, the test is red, then revert and go to 2)b) The test is green before the timer rings, then commit

4) Restart timer5) Refactora) Timer rings, the refactoring is not complete then revert and restart

b) The refactoring is complete before the timer rings, commit and go to 2)

Obs.The timers must run continuously, don't stop to talk! www.mozaicworks.com

Page 20: Coderetreat @AgileFinland Helsinki 2014 11 13

Session 5: Brutal Refactoring Game

www.mozaicworks.com

1) Lack of tests2) Name not from domain3) Name not expressing intent4) Unnecessary if5) Unnecessary else6) Duplication of constant7) Method does more than one thing

8) Primitive obsession

9) Feature envy10) Method too long (> 6 lines)11) Too many parameters (> 3)12) Test – not unitary13) Test – setup too complex14) Test – unclear Act15) Test - more than one assert16) Test – no assert17) Test – too many paths

Page 21: Coderetreat @AgileFinland Helsinki 2014 11 13

Session 6: Choose a constraint

Each pair to choose their own constraint

www.mozaicworks.com

Page 22: Coderetreat @AgileFinland Helsinki 2014 11 13

Closing circle

1) How did you feel? 2) What did you learn today?

3) What will you do differently tomorrow?

www.mozaicworks.com

Page 23: Coderetreat @AgileFinland Helsinki 2014 11 13

Code retreatWhy?

Learn through pairingExtend your comfort zone

PracticeExperiment

Learn new practices

www.mozaicworks.com

Page 24: Coderetreat @AgileFinland Helsinki 2014 11 13

Contact me● Remote pair-programming● Unit testing workshop● Test driven development workshop● Clean code workshop● Refactoring workshop● Legacy code retreat● Working FAST and Safe with existing

code● Code retreat

www.mozaicworks.com

Page 25: Coderetreat @AgileFinland Helsinki 2014 11 13

Code retreatExtend your mentoring & training capacity

Accelerate learning through communities of practice

Grow your functional leaders and top talents

http://www.mozaicworks.com

[email protected]

@adibolb