When we use TDD, our production code goes through a sequence of transformations. I used to think it was a transformation from stupid to intelligent. Rather, the code goes through a sequence of transformation from specific to generic. Returning zero from the score function is a specific case. But the case is in the correct form. It is an integer, and it has the right value.
We make this pass by adding up all the pins in the roll function and storing the sum in a variable named score. Then we change the score function to return that value:.
The Transformation of Economic Law
Notice that we have transformed the constant 0 into the variable score. The algorithm has the same shape as before, i. Why is this a more generic implementation? Because a variable is a generalization of a constant. In other words, the transformation that has taken place is a simple alteration of some part of the solution from a more specific form, to a more generic form!
I used to think that this was merely interesting. I was titillated by the fact sometimes you could perform these simple transformations from specific to generic. Indeed, I think this rule may provide some guidance in choosing the next test to write, and in the manner in which the production code should be implemented in order to pass that test.
This test forces us to abandon the simple implementation of score for a much more complex one. The instance variable score which was updated in the roll function is removed and the score function computes the score from an array of rolls. Once again we have transformed a specific implementation an instance variable that holds a pre-computed score to a more general form a loop that computes the score from an array. Another common transformation can be seen in the prime factors kata where, in order to get the 2 case to pass, we insert an if statement into the implementation.
Who we are
The code transforms from. In this case we are making the code more general by conditionally splitting the execution into two paths.
One path makes all the old tests pass, and the new path makes the new test pass. The prime factors kata is interesting because that transformation happens again in the 4 case where an if statement is added to handle the case where the input variable is divisible by 2;. The new pathway handles the the 4 case by detecting that 4 is divisible by 2, adding 2 to factors , and adjusting n so that the paths can rejoin. More interesting still is that at the 8 case, the inner if statement is transformed into a while statement.
And then for the 9 case the outer if is transformed into a while.
Clearly while is a general form of if. Perhaps you noticed the resemblance that these transformations have to refactorings. However refactorings are used to transform the structure of code without altering its behavior. These transformations are used in order to change the behavior of code. In particular, we use these transformations to make failing tests pass. It should be clear that each of the transformations has a direction. They all transform the behavior of the code from something specific to something more generic. In some cases it is a constant being transformed into a variable, or a variable being transformed into an array.
In others it is an if statement being transformed into a while loop, or a simple sequence getting transformed into recursion. It should also be clear that I have roughly ordered the transformations by their complexity. That is, the transformations at the top of the list are simpler, and less risky, than the transformations that are lower in the list.
So the thing that has piqued my interest lately is the idea that transformations on the top of the list should be preferred to those that are lower.
Take Command of the Most Complex Transformations
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. It was the word wrap kata that got me thinking about this. Offering eye-opening research, innovative prescriptive support, and inspirational stories, The Transformation for the first time gives the reading public clear guidance in the methods that Dr.
Gordon has developed and that he and his team have used to relieve the suffering of hundreds of thousands of children and adults around the world.pintaiwhewe.tk
Your Sale Happens When the Transformation Takes Place - Your Virtual Upline
So, what if we lived in a world where trauma was seen as an accepted, inevitable human experience, and not a pathological anomaly? What if healing and reversing trauma was the key to attaining the joy and fulfillment that every human deserves? During the last decade and a half, massive construction projects in housing, commercial buildings and infrastructure have transformed the landscape of the city, creating a social experiment that has never been replicated on such a massive scale in Africa.
Its conclusions focus on three issues: the livelihoods of low-income residents, their participation in the development of the city, and their social networks of support. Unlike cities in many other African countries, Addis Ababa emerged with only the thinnest traces of a brief colonial legacy: only five years under Italian occupation in the midth century. The book records the current spatial relationships and older architectural forms in the old inner city currently slated for demolition. Numerous maps and illustrations are included to help readers visualize the topics discussed in the volume.
His research and scientific articles focus on the issues of informal settlements, inner city redevelopment and sustainable urban and rural housing. His work experience includes master planning, urban design, urban resilience and the design of medium and large size settlements.