Transformation Priority Premise

Transformation Priority Premise (TPP) is a programming approach developed by Robert C. Martin (Uncle Bob) as a refinement to make the process of test-driven development (TDD) easier and more effective for a computer programmer.

Transformation Priority Premise states that simpler transformations should be preferred:

[...]Refactorings have counterparts called Transformations. Refactorings are simple operations that change the structure of code without changing its behavior. Transformations are simple operations that change the behavior of code. Transformations can be used as the sole means for passing the currently failing test in the red/green/refactor cycle. Transformations have a priority, or a preferred ordering, which if maintained, by the ordering of the tests, will prevent impasses, or long outages in the red/green/refactor cycle.

"Uncle Bob" Martin, "The Transformation Priority Premise", Uncle Bob's Blog

This approach facilitates the programmer doing the simplest possible thing for the purposes of test-driven development as they can explicitly refer to the list of transformations and favor the simpler transformations (from the top of the list) over those further down in the list in the first instance.

The Transformations

  1. ({} → nil) no code at all → code that employs nil
  2. (nil → constant)
  3. (constant → constant+) a simple constant to a more complex constant
  4. (constant → scalar) replacing a constant with a variable or an argument
  5. (statement → statements) adding more unconditional statements.
  6. (unconditional → if) splitting the execution path
  7. (scalar → array)
  8. (array → container)
  9. (statement → tail-recursion)
  10. (if → while)
  11. (statement → non-tail-recursion)
  12. (expression → function) replacing an expression with a function or algorithm
  13. (variable → assignment) replacing the value of a variable.
  14. (case) adding a case (or else) to an existing switch or if

Uncle Bob also explicitly stated: "There are likely others".

gollark: 555s can do logic.
gollark: This is right, I checked.
gollark: No, I knew in all cases.
gollark: In all cases. You're the wrong person.
gollark: Over there.

References

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.