måndag 15 mars 2010

Kurs: TDD Beyond Basics med Uncle Bob

Måndag
Kursen startade lustigt nog med att Bob gick igenom grunderna för partikelfysik, foton, boson, fermions, etc. Började sedan varje delpass med mer partikelfysik. Ett intressant grepp som det ska bli kul att se poängen på.

Resistance and professionals

Vi gick sen igenom vilka problem som TDD-utövare kunde stöta på. Bob angrep passionerat ”organisational resistance”:
As programmers we are professionals. Like doctors, architecs we must ignore organisational pressure. Pressure is put on us for a good reason; to see if we really believe what we are saying. As professionals we know the best way to write code, noone else can tell us that. And as professionals we now the best way is to do test first.
As professionals we also do not want to deliver crap, we want to be proud. And we know that to be fast we need high quality. You are more likely to clean tested code!

Pairing

Bobs råd var att paira ca 50% av tiden, bump it up. Code review kan inte ersätta pairing när det gäller kodkvalitet, men är ett bra komplement för att lära ut sunda principer. Se dock till att det sker på ett sätt där alla är engagerade.

TDD basics


Några lösryckta yttranden som fastnade:
  • 30 seconds cycle time usually, about 1 hour when doing UI.
  • Tidsvinst: Less debug time
  • Trust in the test suite is essential à true maintainability
  • Code coverage bör ligga över 90%, helst 100%! (Vi gjorde ett antal övningar där målet var att nå 100%).
  • To be testable means modularized, able to isolate behaviour which leads to good design.
  • About 33% of code is usually tests, i.e. a 2:1 ratio between production code and tests.
  • I want to be proud of my code

Test Driven Documentation

TDD can stand for
  • Test Driven Development
  • Test Driven Design
  • Test Driven Documentation
“My documentation is formal, it compiles! How about your documentation?”

TDD – några regler

Do one thing

Varje metod/funktion ska bara göra en sak. Det har man uppnått ”when you cannot extract a method à extract till you drop”.
A method that does one thing is testable with one logical assert

Test one thing

Use one logical assert (notice the circular tendency to Do one thing).

Clean test – några mönster

Composed Assert
Composed test result

TDD och GUI

GUI-tests are fragile! Test “under” the GUI, to be continued…

Övningar dag 1

  • HuntTheWumpus. Bump up to 100%. Introduktion med syfte att visa hur enkelt det är att förstå välskriven kod.
  • Environmentalcontroller. Bump up to 100%. What’s good, what’s bad? Många intressanta diskussioner om felaktigheter.
  • Coding DOJO: word wrap. På en timme hann vi tre test J http://codingdojo.org/cgi-bin/wiki.pl?WhatIsCodingDojo

Verktyg

Git, msysgit för windows, http://code.google.com/p/msysgit/
git clone git://github.com/unclebob/HTW.git
git clone git://github.com/unclebob/fitnesse.git
git clone git://github.com/unclebob/environmentcontroller.git

Inga kommentarer: