# Transformation Priority Premise

## Introduction to TPP

If we go back to how we evolve code in TDD, we have these methods:<br>

{% content-ref url="session-1" %}
[session-1](https://asos.gitbook.io/coding-style/module-1-classic-tdd/session-1)
{% endcontent-ref %}

“Use obvious implementation” is ambiguous, what does “obvious implementation” mean? It may mean something for you and something else for another developer. The transformations on the following table are a way to clarify ambiguity the “obvious implementation”.

| #  | Transformation               | Start code          | End code                                          |
| -- | ---------------------------- | ------------------- | ------------------------------------------------- |
| 1  | {} -> nil                    | {}                  | \[return] nil                                     |
| 2  | Nil -> constant              | \[return] nil       | \[return] “1”                                     |
| 3  | Constant -> constant+        | \[return] “1”       | \[return] “1” + “2”                               |
| 4  | Constant -> scalar           | \[return] “1” + “2” | \[return] argument                                |
| 5  | Statement -> statements      | \[return] argument  | \[return] min(max(0, argument), 10)               |
| 6  | Unconditional -> conditional | \[return] argument  | if(condition) \[return] argument else \[return] 0 |
| 7  | Scalar -> array              | dog                 | \[dog, cat]                                       |
| 8  | Array -> container           | \[dog, cat]         | {dog=”DOG”, cat=”CAT”}                            |
| 9  | Statement -> tail recursion  | a + b               | a + recursion                                     |
| 10 | If -> loop                   | if(condition)       | loop(condition)                                   |
| 11 | Statement -> recursion       | a + recursion       | recursion                                         |
| 12 | Expression -> function       | today – birth       | CalculateBirthDate()                              |
| 13 | Variable -> mutation         | day                 | var Day = 10; Day = 11;                           |
| 14 | Case/Switch                  |                     |                                                   |

Transformations on the top of the list should be preferred to those that are lower. It is better (or simpler) to change a constant into a variable than it is to add an if statement. So when making a test pass, you try to do so with transformations that are simpler (higher on the list) than those that are more complex. **Please do not take this table literally**. This is a starting point. Adapt this table to your language and environment.

{% hint style="success" %}

### Hands-on: Bowling Kata

**Learning objectives**

* You should be able to understand and remember the the three methods of moving forward in TDD
* Stick to the rules of TPP

**Success criteria**

*

{% endhint %}
