Transformation Priority Premise (TPP)


Software Development; Coding Techniques; Computer Science


The Transformation Priority Premise (TPP) is a computer programming approach focused on using transformations to optimize the test-driven development (TDD) methodology. Transformations are small changes to code made during each development cycle that modify how code behaves, not simply how it is structured. TPP reduces the possibility that impasses will occur during the development cycle.



The Transformation Priority Premise (TPP) is used to optimize computer code when using a test-driven development (TDD) methodology. TDD is an iterative software development methodology in which multiple unit tests are conducted based on the following steps:

Create a test case for a specific required feature.

Ensure that the test fails.

Create code that causes the test to pass.

Restructure (refactor) the code to remove duplication and make other changes as needed to improve the structure of the code that has been created.

TDD is often described using the red/green/refactor metaphor. First, a test is created that fails (red). Next, code is created that causes the test to pass (green). Finally, code is refactored as necessary. However, one of the problems developers encounter when using TDD is that an impasse may be reached during this cycle. An impasse occurs when the whole algorithm must be rewritten for the current test to pass. This can cause a long delay in development.

Software engineer Robert Cecil Martin (also known by the byname Uncle Bob) developed TPP as a way to reduce the possibility that impasses will occur during TDD. The TPP approach focuses on using transformations to modify code in order to make each new test case pass. Transformations are small changes to code that modify how the code behaves. This contrasts with refactoring, which simply changes how code is structured. In addition, transformations are directional in the sense that they change the behavior of code from more specific to more generic. Examples include changing a constant to a variable, changing an unconditional statement to an if-statement, and replacing statements with recursion.

A transformation changes the behavior of code. This list of transformations is in order of priority when writing code in test-driven development (TDD). In some cases a description is given to explain the transformation.

A transformation changes the behavior of code. This list of transformations is in order of priority when writing code in test-driven development (TDD). In some cases a description is given to explain the transformation.

Martin developed a hierarchy of transformations based on their complexity. For example, the transformation from a constant to a variable is less complex than the transformation from an unconditional statement to an if-statement. The core principle of TPP is that simple transformations have priority over more complex ones when changing code. The least complex transformation needed to pass the current test should be used. Future unit tests should be designed so that the simplest possible transformations can be used to make the code pass. This minimizes the risks inherent in making changes to code and reduces the likelihood of an impasse.


TPP provides developers with an approach to developing code that is designed to address the problems that can arise during TDD. While the process has been shown to work effectively when developing many different algorithms and other software components, questions remain as to how widely it can be applied. The diverse requirements of modern computer programs and the differences in programming languages may provide challenges to the universality of TPP. Further study of the technique is needed to determine if all relevant transformations have been identified, if transformations have been prioritized correctly, and if these processes can be quantified and formalized.


Consider a program that simulates a game of darts in which each player throws three darts per round. Each dart thrown can score 0 (missed the dartboard completely), 5, 10, 15, 20, 25, or 50 (hit the bull's-eye). Such a program might use a function to calculate a player's score after one round. To apply TPP in developing such a function, the developer might begin by creating a unit test for a simple test case: when all three darts miss the board completely.

First, a procedure is used to create the test. This procedure calls the computeScoreForRound function to compute the score for the round, passing it the values for each dart thrown. If the correct score is returned (0), the function returns 1, indicating success. If not, it returns 0, indicating failure. This function is shown below.

Transformation Priority Premise (TPP)

Next, a function is created that returns 0. This will enable the test to pass.

Transformation Priority Premise (TPP)

This completes the first unit test. Next, a new case is added in which two darts miss the board and one dart hits the board, scoring 5 points.

Transformation Priority Premise (TPP)

In order to pass this test, the code is changed using a constant to variable transformation.

Transformation Priority Premise (TPP)

Note how the new test is passed by transforming a constant value (0) in the first unit test to a variable, roundScore, in the second test.


TPP promises to improve the efficiency of developers working in a TDD environment by helping to avoid impasses. It provides useful means of overcoming obstacles in designing and implementing unit tests. Though the specific list of transformations applied may vary among developers, the premise of prioritizing simplicity establishes a system that is easy to follow. The technique is likely to increase in importance and applicability as it is studied, improved, and formalized.

—Maura Valentino, MSLIS

Beck, Kent. Test-Driven Development: By Example. Pearson, 2014.

Farcic, Viktor, and Alex Garcia. Test-Driven Java Development. Packt Publishing, 2015.

Haverbeke, Marijn. Eloquent JavaScript: A Modern Introduction to Programming. 2nd ed., No Starch Press, 2014.

MacLennan, Bruce J. Principles of Programming Languages: Design, Evaluation, and Implementation. 3rd ed., Oxford UP, 1999.

Schneider, David I. Introduction to Programming Using Visual Basic. Pearson, 2016.

Scott, Michael L. Programming Language Pragmatics. 4th ed., Morgan Kaufmann Publishers, 2016.

Van Roy, Peter, and Seif Haridi. Concepts, Techniques, and Models of Computer Programming. Massachusetts Institute of Technology, 2004.