How Do We Teach TDD Keith Ray
description
Transcript of How Do We Teach TDD Keith Ray
![Page 1: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/1.jpg)
How Do We Teach TDD?
Considering the Dreyfus Model of Learning
C. Keith Ray
Coach, Trainer, Developer at Industrial Logic, [email protected] twitter: @ckeithray
http://industriallogic.com
![Page 2: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/2.jpg)
What's TDD?
TDD is Test-Driven Development. The simple description of TDD is:
Red-Green-Refactor-Repeat: write a test that fails (red), write just enough code to make it pass (green), then refactor to a good design (aka "simple code"), and repeat.
![Page 3: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/3.jpg)
Dreyfus Model
Dreyfus came up with a model of learning. He named five levels:
NoviceAdvanced BeginnerCompetent ProficientExpert
See http://en.wikipedia.org/wiki/Dreyfus_model_of_skill_acquisition
![Page 4: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/4.jpg)
Novice
Completely new to the thing to be learned.
Wants recipes, rules, constraints
They don't know what "good" look likes yet, so they want fast feedback.
Craves rules.
![Page 5: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/5.jpg)
Advanced beginner
Knows the rules, but not all the contexts for them, knows just enough to be "dangerous."
As a software developer, probably writing "big balls of mud".
Better to have them learning in a safe environment to learn from their mistakes.
5
![Page 6: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/6.jpg)
Competent
Can do a task without needing instructions.
Identifies patterns and uses them, mostly in appropriate contexts.
May be offended if you treat them like a Novice or Advanced Beginner.
![Page 7: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/7.jpg)
Proficient
Good, but now trying to become expert.
Lots of experience / practice.
Knows how to do stuff, but can't tell people how to do it.
(Teaching has its own Novice to Expert levels)
![Page 8: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/8.jpg)
Expert
Beyond rules.
Working on instinct.
Needs to compare notes with other experts.
Arguing about their subject refines their understanding of it.
![Page 9: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/9.jpg)
TDD seems so simple, so why is it hard to teach?
Teacher: it's red, green, refactor, repeat.
<long time later>
Student: ok, here's all my tests!
Teacher: where's the code?
Student: I haven't written it yet.
Teacher: Photo by striatic
![Page 10: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/10.jpg)
TDD seems so simple, so why is it hard to teach?
Teacher: it's red, green, refactor, repeat.
<long time later>
Student: here's my first test. [400 lines of code in a single test.]
Photo by Marcin Wichary
![Page 11: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/11.jpg)
TDD seems so simple, so why is it hard to teach?
Teacher: it's red, green, refactor, repeat.
Student: <Doesn't understand why the test should fail before it is made to pass, so writes code and tests so that the tests usually pass the first time they are run.>
oops
![Page 12: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/12.jpg)
TDD seems so simple, so why is it hard to teach?
Teacher: it's red, green, refactor, repeat.Student: here's my tests and code.Teacher: nice, but you've got a very large class, with a very large method, and all your tests are repeating lots of code. Did you refactor?Student: I thought we'd refactor next month!
![Page 13: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/13.jpg)
TDD seems so simple, so why is it hard to teach?
Because each of the steps of TDD require skills in three main areas:
Writing tests.
Writing simple code.
Refactoring.
![Page 14: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/14.jpg)
There's more, Refactoring Requires:
Recognizing symptoms of bad design (code smells).
Making small transformations to improve the design. (The actual Refactorings.)
Recognizing good design (aka "Simple Code")
![Page 15: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/15.jpg)
"Simple Design"
Kent Beck's rules for simple design were:1. Runs all the tests.2.No duplication.3. Expresses the developer's
intentions.4.Minimizes the number of classes
and methods.
Photo by GN
![Page 16: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/16.jpg)
Getting back to Dreyfus...We teach using web-base materials in live training and via coaching.
Our web-based materials assume the student is in the Novice stage of learning about TDD.
We also assume the student is at least in the Competent stage as a programmer.
We encourage pairing of students — it makes a large improvement in learning.
![Page 17: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/17.jpg)
What Novices WantA "novice" is completely new to a subject.They want rules, recipes, formulas, step-by-step how-to-do-it.They don't know enough to judge their own results, so they need fast, frequent feedback by coach or trainer.
Photo by Steve Snodgrass
![Page 18: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/18.jpg)
Breaking TDD Skill-Sets into Novice-sized
Pieces
![Page 19: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/19.jpg)
Demo Video
Videos are usually short (around 5 minutes) and demonstrate a technique or make a point.
![Page 20: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/20.jpg)
Demo Quizzes
We have a variety of quiz types. Students can comment on quiz answers or post questions and get a
prompt response from Industrial Logic staff.
![Page 21: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/21.jpg)
Demo: Exercises
TDDing Big Bill's Billing System
Task 1: Calculate A Simple Phone Bill
Task 2: Calculate Excess Minutes
Task 3: etc.
Student writes the code, compares it with solution(s).
Almost all solutions are demonstrated in video form and downloadable code.
![Page 22: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/22.jpg)
Demo: CritiquesYour score was 62% based on
our Automated Critique.This ranks you as Intermediate.
A Graph of Your TDD Activity
See several examples here.
![Page 23: How Do We Teach TDD Keith Ray](https://reader034.fdocuments.in/reader034/viewer/2022052522/553b7d404a7959fe7f8b468a/html5/thumbnails/23.jpg)
ConclusionOur web-based training with critiques provides feedback that Novices and Advanced Beginners need, and which would otherwise require one-to-one coaching. This works for our live training as well as purely web-based training.
Try it out: http://elearning.industriallogic.com
(PS: Competent, Proficient, and TDD Experts should try Sessions.)
See also Dan North appling the Dreyfus model to a more general level of "best practices": http://www.infoq.com/articles/better-best-practices