ArticleslgStudy

computer science

Transformation Priority Premise

Transformation Priority Premise is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Transformation Priority Premise rather than just read about it. In short: 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.

Key takeaways

  • Transformation Priority Premise belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Transformation Priority Premise to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Transformation Priority Premise from memory before moving on to harder problems.

Reference excerpt

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. 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 Transformation Priority Premise is a name given to the mental structure TDD’ers build up over time as to balance your code from being too specific, rather than generic. The idea is that with each example you add to the tests you move up the Transformation Priority list, making your code more generic, so able to handle more of the cases. In contrast, your tests, with more examples, become ever more specific and focused on the problem. So you start with a constant for your first test, for your next test you might change that constant to an “if” for the next step you might introduce a loop. Each time you’re moving up the priority premise. The aim of following this structure is to avoid Accidental Complication, and to add only to Essential Complication. Each step is the smallest possible change you can make to implement only the code required to implement the examples given in the test..

The Transformations Source:

({} → nil) no code at all → code that employs nil (nil → constant) (constant → constant+) a simple constant to a more complex constant (constant → scalar) replacing a constant with a variable or an argument (statement → statements) adding more unconditional statements. (unconditional → if) splitting the execution path (scalar → array) (array → container) (statement → tail-recursion) (if → while) (statement → non-tail-recursion) (expression → function) replacing an expression with a function or algorithm (variable → assignment) replacing the value of a variable. (case) adding a case (or else) to an existing switch or if Robert Martin also explicitly stated: "There are likely others", and [I] think that the priority list is language specific... In Java, for example, we might move (if→while) and (variable→assignment) above (statement→tail-recursion) so that iteration is always preferred above recursion, and assignment is preferred above parameter passing ... because Java is not a functional language.

How to use the Transformations in Practice Ridlehoover clarifies that the Transformations help you pick which tests to write and in what order.

[The Transformations] can actually help us pick which tests we should write in what order. For example, if we decide to write a test that requires us to add an if statement to our code, that test requires the “unconditional –> if” transformation. Knowing that, we can try to think of other tests that rely solely on transformations higher up the list. The ultimate reward is that by writing our tests using transformation priority order, we should not ever get to a point where one test causes us to rewrite an entire method. Corey Haines provides a live coding demo (Roman Numerals Kata) where he solves a coding challenge utilising the Transformations.

References

Roman Numerals Kata with Commentary Transformation Priority Premise Applied The Transformation Priority Premise explained by Uncle Bob

External links Bob Martin's original blog post on TPP A subsequent blog post in which Bob Martin extended the list of transformations Video recording of his original presentation of TPP at NDC (Norwegian Developers Conference) 2011 on YouTube

Worked examples

Example 1 — a first encounter with Transformation Priority Premise

Start with the simplest possible case. Write down what Transformation Priority Premise claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Transformation Priority Premise before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Transformation Priority Premise ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Transformation Priority Premise

In research
Transformation Priority Premise appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Transformation Priority Premise in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Transformation Priority Premise is common in secondary-school and first-year university syllabi. It links to neighbouring topics Extreme programming, Software development philosophies, Software development process, so understanding it makes those chapters shorter.
In everyday life
Look for Transformation Priority Premise outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Transformation Priority Premise in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Transformation Priority Premise means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Transformation Priority Premise out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Transformation Priority Premise in simple terms?

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.

Why does Transformation Priority Premise matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Transformation Priority Premise?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Transformation Priority Premise.

Tags

  • Extreme programming
  • Software development philosophies
  • Software development process
  • Software testing

Keep exploring