50
Thank you to our Sponsors Bryan Beecham and Mike Bowler TDD with LEGO Monday, 11 November, 13

TDD with LEGO at SDEC13

Embed Size (px)

DESCRIPTION

Here is the TDD LEGO presentation as given in Winnipeg at SDEC13

Citation preview

Page 1: TDD with LEGO at SDEC13

Thank you to our Sponsors

Bryan Beecham and Mike BowlerTDD with LEGO

Monday, 11 November, 13

Page 2: TDD with LEGO at SDEC13

Understanding TDD with LEGO

Bryan Beecham@BillyGarnet

Mike Bowler@mike_bowler

Monday, 11 November, 13

Page 3: TDD with LEGO at SDEC13

Exercise - 1

Open up one LEGO packet

Build a person and a house out of LEGO

Monday, 11 November, 13

Page 4: TDD with LEGO at SDEC13

Admire your work

Take a photo. Upload to Twitter. Brag to your friends.

Monday, 11 November, 13

Page 5: TDD with LEGO at SDEC13

Reference

Test-DrivenDevelopmentBy ExampleKent Beck

Monday, 11 November, 13

Page 6: TDD with LEGO at SDEC13

What is the goal of TDD?

It creates clean code that works ~ Ron Jefferies

Monday, 11 November, 13

Page 7: TDD with LEGO at SDEC13

TDD

It is a predictable way to develop. You know when you are finished, without having to worry about a long bug trail.

Monday, 11 November, 13

Page 8: TDD with LEGO at SDEC13

TDD

It gives you a chance to learn all of the lessons that the code has to teach you. If you only slap together the first thing you think of, then you never have time to think of a second, better thing.

Monday, 11 November, 13

Page 9: TDD with LEGO at SDEC13

TDD

It improves the lives of the users of your software.

Monday, 11 November, 13

Page 10: TDD with LEGO at SDEC13

TDD

It lets your teammates count on you, and you on them.

Monday, 11 November, 13

Page 11: TDD with LEGO at SDEC13

TDD

It feels good to write it.

Monday, 11 November, 13

Page 12: TDD with LEGO at SDEC13

The MantraRed - Green - Refactorphoto from doolwind.com

Monday, 11 November, 13

Page 13: TDD with LEGO at SDEC13

The Mantra - Red

Write a small test that doesn’t work

Monday, 11 November, 13

Page 14: TDD with LEGO at SDEC13

The Mantra - Green

Do the minimum to make the test work

Monday, 11 November, 13

Page 15: TDD with LEGO at SDEC13

The Mantra - Refactor

Eliminate duplication

Monday, 11 November, 13

Page 16: TDD with LEGO at SDEC13

Exercise - 2

Build a person and a house with TDD

Monday, 11 November, 13

Page 17: TDD with LEGO at SDEC13

Prepare your environment

Clear the area in front of you. This is your program.

The perfect program!

Monday, 11 November, 13

Page 18: TDD with LEGO at SDEC13

First Test

Does the person exist? No?

Monday, 11 November, 13

Page 19: TDD with LEGO at SDEC13

Hurray!!!We failed the test! Celebrate! High 5s!

Monday, 11 November, 13

Page 20: TDD with LEGO at SDEC13

Minimum to pass the test

Add a block. Can that be a person?

Monday, 11 November, 13

Page 21: TDD with LEGO at SDEC13

Hurray!!!

The person now exists!

Not very impressive but it could represent a person.

We passed the test! We are rocking now!

Monday, 11 November, 13

Page 22: TDD with LEGO at SDEC13

Refactor

Remove any duplication. In this case we’re good.

Monday, 11 November, 13

Page 23: TDD with LEGO at SDEC13

Same thing for house

Blah, blah, awesome recreation by speaker...everyone is extremely impressed and are thinking this might be the best session of the whole conference.

Monday, 11 November, 13

Page 24: TDD with LEGO at SDEC13

We need a new test

The house is taller then the person.

Assert.IsTrue(house.height > person.height);

Monday, 11 November, 13

Page 25: TDD with LEGO at SDEC13

Hurray!!! - More FailureThe person is the same size so we fail this test. Well done!

Monday, 11 November, 13

Page 26: TDD with LEGO at SDEC13

Failure = Learning Opportunity

If you’re not failing, you’re not learning.

If you’re not learning...

Monday, 11 November, 13

Page 27: TDD with LEGO at SDEC13

Minimum to pass the test

From the audience this time. Anyone? Bueller?

Monday, 11 November, 13

Page 28: TDD with LEGO at SDEC13

Hurray!!! - Success

Alright, we passed the test.

Monday, 11 November, 13

Page 29: TDD with LEGO at SDEC13

Refactor

Still very simple. Still nice and clean.

Monday, 11 November, 13

Page 30: TDD with LEGO at SDEC13

Software Requirements

Software must do three things:

It must work

It must be understandable

It must be updatable

Monday, 11 November, 13

Page 31: TDD with LEGO at SDEC13

We need a new test

Is the house wider then the person? No?

We failed another test! Awesome! We are learning a lot about improvements that are needed to our code.

Let’s do the minimum to pass the test.

Any duplication to remove?

Monday, 11 November, 13

Page 32: TDD with LEGO at SDEC13

We need a new test

Can your person fit in the house? Yikes! No.

We failed another test! Awesome! We are learning so much about what our customer needs.

Let’s do the minimum to pass the test.

Any duplication to remove?

Monday, 11 November, 13

Page 33: TDD with LEGO at SDEC13

Exercise - 3 Partners!

Break into groups of two for this next exercise.

When developers do this we call it Pair ProgrammingBerkley photo from the web

Monday, 11 November, 13

Page 34: TDD with LEGO at SDEC13

New Requirements

Your new program needs to have:

A person

A house

A tree

An animal

A vehicle

Monday, 11 November, 13

Page 35: TDD with LEGO at SDEC13

Let’s Practice!Work together and write down a new test

Build minimally pass the test

Repeat (Don’t worry about Refactoring for now)

Here’s a few if you get stuck:

Is the house at least x bricks tall?

Is the tree the same size as the house?

Is the animal smaller than the person?

Monday, 11 November, 13

Page 36: TDD with LEGO at SDEC13

New Requirements

Your new program needs to have:

A person

A house

A tree

An animal

A vehicle

Monday, 11 November, 13

Page 37: TDD with LEGO at SDEC13

Review

Let’s take a minute to walk around and look at everybody’s creations!

Taking breaks and stretching your muscles (eyes, legs, arms, back) is very important to stay healthy.

Monday, 11 November, 13

Page 38: TDD with LEGO at SDEC13

Apology

You may have to break your wonderful new structures for the components for the next section.

Don’t worry, there is more building to come!

Please do take a photo. Remember @BillyGarnet and @mike_bowler #SDEC13 if you’re tweeting about the amazing time you’re having!

Monday, 11 November, 13

Page 39: TDD with LEGO at SDEC13

Refactoring

Refactoring is the process of changing a software system in such a way that it does not alter the external behaviour of the code yet improves its internal structure.~Martin Fowler

Monday, 11 November, 13

Page 40: TDD with LEGO at SDEC13

Super Fast BreakStand up and stretch - really, it’s important!Share something you’ve learned with a neighbour!

Monday, 11 November, 13

Page 41: TDD with LEGO at SDEC13

Exercise 4 -Team Build

Each table will come up with a large structure with lots of parts to build. (airport, zoo, amusement park...)

You will be a software team, working in pairs, contributing to the large team structure (the build) at your table.

Monday, 11 November, 13

Page 42: TDD with LEGO at SDEC13

Decide on an idea

Shh...don’t tell the other tables.

(Jeopardy music...)

Monday, 11 November, 13

Page 43: TDD with LEGO at SDEC13

Break it into components

Take a minute to write out a few of the components that need to be built (product backlog).

Each pair will build a component through TDD.

We will then add the sections to the big project. Make sure you don’t break your teams tests!

Write your test on paper, fail, then add lego to pass.

Monday, 11 November, 13

Page 44: TDD with LEGO at SDEC13

Demo time!

A few teams will now present their creation.

Please share the tests that you came up with and point out the solution.

Monday, 11 November, 13

Page 45: TDD with LEGO at SDEC13

Review

Test-Driven Development / Design

Refactoring

Pair Programming

A bit of developer speak

Experience working on a software team

Monday, 11 November, 13

Page 46: TDD with LEGO at SDEC13

Questions?

Bryan Beecham@[email protected]

Mike Bowler@[email protected]

Please separate the lego bricks into their respective colours

Monday, 11 November, 13

Page 47: TDD with LEGO at SDEC13

No really, it’s over

Monday, 11 November, 13

Page 48: TDD with LEGO at SDEC13

There are no more slides

Monday, 11 November, 13

Page 49: TDD with LEGO at SDEC13

No trailers

Monday, 11 November, 13

Page 50: TDD with LEGO at SDEC13

Looking for more?

Check out http://www.humanrefactor.com

Links to HumanRefactoring, and soon more LEGO!

Monday, 11 November, 13