add tdd to your toolbox: an introduction to tdd

12
Add TDD to your toolbox an introduction for beginners Audrey Troutt @auditty

Upload: atroutt

Post on 27-Nov-2014

225 views

Category:

Technology


0 download

DESCRIPTION

Introduction to TDD, test-driven development. Not included is a live coding demonstration of TDD in practice. Look at the link on the last slide for videos of other people doing TDD.

TRANSCRIPT

Page 1: Add TDD to your Toolbox: an introduction to TDD

Add TDD to your toolboxan introduction for beginners

Audrey Troutt @auditty

Page 2: Add TDD to your Toolbox: an introduction to TDD

Audrey Troutt @auditty

What is TDD? Test-Driven Development

Page 3: Add TDD to your Toolbox: an introduction to TDD

Audrey Troutt @auditty

Three conditions to achieve a flow state:

1. clear set of goals and progress

2. clear and immediate feedback

3. confidence in one's ability

Csikszentmihalyi, M.; Abuhamdeh, S. & Nakamura, J. (2005), "Flow", in Elliot, A., Handbook of Competence and Motivation

Page 4: Add TDD to your Toolbox: an introduction to TDD

“TDD is dead. Long live testing.” -David Heinemeier Hansson

Read more: http://bit.ly/1foLebI

Audrey Troutt @auditty

Page 5: Add TDD to your Toolbox: an introduction to TDD

Materials needed:Source code

Unit testing frameworkUnderstanding of requirements

Audrey Troutt @auditty

Page 6: Add TDD to your Toolbox: an introduction to TDD

Simple Case: There’s a bug

Audrey Troutt @auditty

Page 7: Add TDD to your Toolbox: an introduction to TDD

Use Case: From the Ground Up

Audrey Troutt @auditty

Page 8: Add TDD to your Toolbox: an introduction to TDD

“As the tests get more specific, the code gets more generic.”

-Uncle Bob Martin

Audrey Troutt @auditty

Read more: http://bit.ly/1Bs2h70

Page 9: Add TDD to your Toolbox: an introduction to TDD

● ({}–>nil) no code at all->code that employs nil

● (nil->constant)

● (constant->constant+) a simple constant to a more complex constant

● (constant->scalar) replacing a constant with a variable or an argument

● (statement->statements) adding more unconditional statements.

● (unconditional->if) splitting the execution path

● (scalar->array)

● (array->container)

● (statement->recursion)

● … and so on

Audrey Troutt @auditty

Read more: http://bit.ly/1Bs2h70

Page 10: Add TDD to your Toolbox: an introduction to TDD

Pros:● More tests● More testable code● Discover missing

requirements sooner● Uncover novel designs● Increased quality● Refactor/add on with

confidence● Doesn’t generally take

more time● May start conversations

Cons:● First time setup of test

framework takes extra time

● Not always practical (if requirements are not well defined)

● Makes changing object model harder

● May start conversations

Audrey Troutt @auditty

Page 11: Add TDD to your Toolbox: an introduction to TDD

“I credit TDD for teaching me how to test, and I still get huge benefits when I TDD. It’s not perfect, but no one technique is the key to magically producing better code.”

-Justin Weiss

Audrey Troutt @auditty

Read more: http://bit.ly/1BVRR1y

Page 12: Add TDD to your Toolbox: an introduction to TDD

Practice http://codekata.com/

Learn from others http://katas.softwarecraftsmanship.org/

Audrey Troutt @auditty