The Transformation Priority Premise is a tool invented by Robert “Uncle Bob” C. Martin that helps in discovering the sequence in which to write unit tests and production code in Test-Driven Development. This talk gives an overview of the Transformation Priority Premise - and Aliens.
3. N = R*
× fp
× ne
× fl
× fi
× fc
× L
R*
average rate of star formation in our galaxy
fp
fraction of stars that have planets
ne
average number of planets per star that can
potentially support life
fl
fraction of planets that actually develop life
fi
fraction of planets that develop intelligent life
fc
fraction of civilizations that develop technology
L length of time for which such civilizations
release detectable signals into space
The Drake equation
Dr. Frank Drake
6. Speculation
● We are the only ones
● Intelligent life destroys itself
● Intelligent life destroys others
● Life is periodically destroyed by nature
● Most universes are (too) young
● Too far scattered
● Too expensive to spread through galaxy
7. Speculation (continued)
● We’re not around long enough
● We’re not listening properly
● Radio signals only used for brief period
● Civilizations isolate themselves
● They are too alien
● They are non-technological
● Everyone is listening, no one transmitting
8. Speculation (continued)
● Earth is deliberately not contacted (zoo)
● Earth is purposely isolated (planetarium)
● It is dangerous to communicate
● Self-fulfilling Fermi-Paradox
● They are undetected
● They are unacknowledged
9. Agenda
● Reprise: TDD - The Three Laws and the
Red-Green-Refactor Cycle
● Reprise: What is Refactoring?
● Definition: What is Transformation?
● The (current) Priority list of Transformations
● Example
10. Questions to Cover
● What is a Transformation?
● Why do they have Priorities?
● Why is it a Premise?
● How is it related to Refactoring and TDD?
● How can I use it? How does it help me?
11. The Three Laws of TDD
1. You can’t write any production code until you
first have written a failing unit test.
2. You can’t write more of a unit test than is
sufficient to fail, and not compiling is failing.
3. You can’t write more production code than is
sufficient to pass the currently failing unit
test.
12. The Red-Green-Refactor Cycle
Red: Write as much of test
as is sufficient to fail.
Green: Write as much of
production code as is
sufficient to pass.
Refactor: Well, refactor!
15. List of Transformations
● {} → nil
● nil → constant
● constant → constant +
● constant → scalar
● statement → statements
● unconditional → if
● scalar → array
● array → container
● statement → recursion
● if → while
● expression → function
● variable → assignment
16. How it works
● The first unit test should demand the first
transformation.
● The next unit test should demand the
simplest next transformation possible.
● Apply the simplest transformations that still
satisfy the test.
● And: Red → Green → Refactor
17. Who invented it?
Robert “Uncle Bob” C. Martin
● Red-Green-Refactor
● Three Laws of TDD
● Transformation Priority Premise
● SOLID Principles
● …