Top Banner
Amir Barylko - TDD MavenThought Inc. AMIR BARYLKO WHY TDD? WPG RUBY UG 2011
20
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: why-tdd

Amir Barylko - TDD MavenThought Inc.

AMIR BARYLKO

WHY TDD?

WPG RUBY UG 2011

Page 2: why-tdd

Amir Barylko - TDD MavenThought Inc.

INTROWhy projects fail?

Reality CheckNo more excuses

Why TDD?

Page 3: why-tdd

Amir Barylko - TDD MavenThought Inc.

WHY PROJECTS FAIL?

•Delivering late or over budget

•Delivering the wrong thing

•Unstable in production

•Costly to maintain

Page 4: why-tdd

Amir Barylko - TDD MavenThought Inc.

REALITY CHECK

•It is impossible to gather all the requirements at the beginning of a project.

•Whatever requirements you do gather are guaranteed to change.

•There will always be more to do than time and money will allow.

Page 5: why-tdd

Amir Barylko - TDD Workshop PRDC 2011 MavenThought Inc.

NO MORE EXCUSES

• It works on my computer!

• It was like that when I got here!

• The previous developer didn’t know XXXX!

• We need a satellite connection in order to run it!

• We can’t reproduce the error!

• We can’t test that!

Page 6: why-tdd

Amir Barylko - TDD Workshop PRDC 2011 MavenThought Inc.

WHY TDD?

•Prove that your code works

•Avoid waste (debugging)

• Increment code quality

•Better design

•Regression tests as byproduct

•Make changes with confidence

•Bring back the joy of coding!

Page 7: why-tdd

Amir Barylko - TDD MavenThought Inc.

APPLYING TDDIteration 0 .. N

Quality as a Driver Red - Green - Refactor

Page 8: why-tdd

Amir Barylko - TDD MavenThought Inc.

ITERATION 0

• Flush out architecture.

• Setup Testing harness for TDD and BDD.

• Setup continuous integration.

• Setup scripts to build, deploy, etc.

• Setup visual communication tools.

Page 9: why-tdd

Amir Barylko - TDD MavenThought Inc.

ITERATION 1.. N

• Start by Story Planning

• Pair programming (switching often)

• Daily Scrum

• End with Retrospective

Every day!

Page 10: why-tdd

Amir Barylko - TDD MavenThought Inc.

QUALITY AS A DRIVERRed

GreenRefactor

BDD

TDD

Red

GreenRefactor

Page 11: why-tdd

Amir Barylko - TDD MavenThought Inc.

RED

•Write a test that fails

•Relax, is ok if it compiles

Page 12: why-tdd

Amir Barylko - TDD MavenThought Inc.

GREEN

•Try to make the test pass

•Do a simple solution

•Use default values (not throwing exceptions)

•Don’t worry if the code “smells”

Page 13: why-tdd

Amir Barylko - TDD MavenThought Inc.

REFACTOR

•Avoid repeating code

•Avoid hardcoding dependencies

•Avoid “write only” code

•Refactor with confidence!

•Run all tests if possible

Page 14: why-tdd

Amir Barylko - TDD MavenThought Inc.

DEMOMediaLibrary

AddTop10

Page 15: why-tdd

Amir Barylko - TDD MavenThought Inc.

SUMMARYLimits

BenefitsChallengesAdoption

Page 16: why-tdd

Amir Barylko - TDD MavenThought Inc.

LIMITS OF TDD

• Unit test

• Integration test

• Acceptance test

Page 17: why-tdd

Amir Barylko - TDD MavenThought Inc.

BENEFITS

•Let the methodology drive

•It will save your bacon!

•High quality the whole way!

•Very few bugs!

•Do your duty as developer!

Page 18: why-tdd

Amir Barylko - TDD MavenThought Inc.

CHALLENGES

• Very different from conventional testing

• Many developers find it complex to learn at first

• Hard to start without a Mentor

• Management buy in

• Difficult to keep under deadline pressure

• Beware of code coverage!

Page 19: why-tdd

Amir Barylko - TDD MavenThought Inc.

ADOPTION

• Find Mentor/Couch/Trainer

• Small iterations

• Have metrics ready (velocity, etc)

• Do whatever works for you

• Find out which tools will benefit you

• Automate, automate, automate!

Page 20: why-tdd

Amir Barylko - TDD MavenThought Inc.

QUESTIONS?