Transcript XP again

XP Again
(Mostly TDD)
26-Jul-16
Test-Driven Development

Advantages of writing tests first:






XP slogans:



Clarifies what the methods are supposed to do
Methods are testable
Methods tend to be simpler and single-purpose
Methods tend to be more independent of the environment
Tests get written
“Test Everything That Could Possibly Break”
“If it hasn’t been tested, it doesn’t work.”
One of the XP principles is: Respect

Trust your team members not to submit nonworking code
TDD development cycle

Here’s how TDD should be done:
while (program isn’t complete) {
write a nonworking “stub” method
write a test for that method
run the test and make sure it fails
do {
improve the method
test the method
} while (the test fails)
}

It’s OK to start with a large number of stubs, but make
each method work before you go on to the next
TDD maintenance

After your program is fully written and tested, bugs
can still appear


Usually this is something you forgot to test
Here’s what to do:


First, write a test case that exposes the error (by failing)
Then (and only then) correct the code
Suggestions for working with partners

Make sure you are clear on what classes and methods
are to be written



Follow the exact specs given on the assignment
If you want additional methods, agree on what they are
Divide up the effort (by class or by method)



Do TDD
Write tests for your own code, not your partners code
Give your partner working code


Remember: “If it hasn’t been tested, it doesn’t work.”
Agree who is to do the last-minute integration testing
(and submission)
Other XP terms

DTSTTCPW




DRY


“OnceAndOnlyOnce”
Test Infected



“Don’t Repeat Yourself”
OAOO


“Do The Simplest Thing That Could Possibly Work”
If it needs to be more efficient, that’s best done with simple,
understandable code
The compiler is better at optimization than you are
“When you can't even go pee unless you have a GreenBar”
Source: http://c2.com/cgi/wiki?XpGlossary
YAGNI

“You Ain’t Gonna Need It”
The End