Code retreat @BMW Car IT

35
1.BMW Car IT Code Retreat [email protected]

description

The slides I used during our code retreat at BMW Car IT.

Transcript of Code retreat @BMW Car IT

Page 2: Code retreat @BMW Car IT

1. code

2. delete

3. repeat

6x

Page 3: Code retreat @BMW Car IT

The point of a code retreat is not to make progress on the problem. The point is to

write perfect code!

Corey Haines

Page 4: Code retreat @BMW Car IT

In each session...

1. Set a goal

2. Try to reach it

3. Destroy your code

4. Retrospect

Page 5: Code retreat @BMW Car IT

Pair Programming

• Talk about your assumptions, short-term goals, general direction

• Switch roles frequently

• Communication: "This method is too long" vs "Could we make this method shorter?"

• Exercise: Ping-Pong-Pairing - one person writes a test, the other tries to fix it.

more http://jamesshore.com/Agile-Book/pair_programming.html

Page 6: Code retreat @BMW Car IT

Session IGet to know the problem...

Page 7: Code retreat @BMW Car IT

Conway‘s Game of Life

Page 8: Code retreat @BMW Car IT

Conway‘s Game of Life

Page 9: Code retreat @BMW Car IT

1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.

Page 10: Code retreat @BMW Car IT

1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.

Page 11: Code retreat @BMW Car IT

1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.

Page 12: Code retreat @BMW Car IT

2. Any live cell with two or three live neighbours lives on to the next generation

Page 13: Code retreat @BMW Car IT

2. Any live cell with two or three live neighbours lives on to the next generation

Page 14: Code retreat @BMW Car IT

3. Any live cell with more than three live neighbours dies, as if by overcrowding.

Page 15: Code retreat @BMW Car IT

3. Any live cell with more than three live neighbours dies, as if by overcrowding.

Page 16: Code retreat @BMW Car IT

4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

Page 17: Code retreat @BMW Car IT

4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

Page 18: Code retreat @BMW Car IT

Notes

• All rules are applied simultaneously

• Start by focusing on the rules

• No GUI - use tests instead

Page 19: Code retreat @BMW Car IT

Session IIEverything is an object.

Page 20: Code retreat @BMW Car IT

Cell

Cell

Cell Cell

neighbours

Example

Cell Cell

Cell

Cell

vs.

Page 21: Code retreat @BMW Car IT

Challenge

• Thou shalt not use arrays.

Page 22: Code retreat @BMW Car IT

Session IIITest-drive your design.

Page 23: Code retreat @BMW Car IT

Test-first ≠ Test-driven

Page 24: Code retreat @BMW Car IT

TDD

Write a failingunit test

Make the test pass

Refactor

Page 25: Code retreat @BMW Car IT

TDD as if you meant it

• Write one failing test

• Make the test pass by writing implementation code in the test

• Create a new implementation method/function by:

• extract method on implementation code from (2), or

• moving implementation code from (2) into an existing method

• Only ever create new methods in the test class

• Only ever create implementation classes to provide a destination for extracting a method created as per (4).

• Populate implementation classes by moving methods from a test class

• Refactor

Page 26: Code retreat @BMW Car IT

Example

Page 27: Code retreat @BMW Car IT

Challenge

• Thou shalt TDD as if thou meant it.

• Thou shalt not use the debugger.

• Thou shalt know in advance which test will fail.

Page 28: Code retreat @BMW Car IT

Session IVIts all about the looks...

Page 29: Code retreat @BMW Car IT

"There are two hard problems in computer science: cache invalidation, naming things, and

off-by-one errors."

Eric Florenzano / Phil Karlton

Page 30: Code retreat @BMW Car IT

"There are two hard problems in computer science: cache invalidation, naming things, and

off-by-one errors."

Eric Florenzano / Phil Karlton

Page 31: Code retreat @BMW Car IT

Example

Page 32: Code retreat @BMW Car IT

Challenge

• Thou shalt use good names.

• Thou shalt express your intend by method names.

• Thou shalt have only methods with LOC < 3.

Page 33: Code retreat @BMW Car IT

Session VMore challenges...

Page 34: Code retreat @BMW Car IT

Challenge

• Thou shalt use only functions and constants.

or

• Thou shalt not use loops (while, for, iterators,..).

Page 35: Code retreat @BMW Car IT

Session VIThe end game...