Gil Zilberfeld explains refactoring in legacy code, when using ApprovalTests and something unexpected happens

Refactoring Kung-Fu, Part VI

Ok, time to run the test. Well, that’s interesting. The test is not even running until the end, we’re crashing before it completes. Let’s see what’s wrong. Seems that this line breaks: List<Ingredient> fillingIngredients = new ArrayList<Ingredient>(ingredients.subList(1, ingredients.size() – 1)); when running the case where dish includes: Sauce = Pesto, Read more…

Refactoring Kung-Fu, Part V

Last time we talked about flow analysis in the code. We figured out the cases we want covered. But, even for these cases, we don’t know what the expected result is. It’s worse than that in the real world. In our case, after we’ve drawn the boundary and decided which code Read more…

Gil Zilberfeld explains about refactoring test cases in legacy code

Refactoring Kung Fu – Part IV

The current code version we’re talking about is tag 1.1. Last time, we have surrounded our code with a boundary, doing some early refactoring. We now know the entry points, and the exits are covered by interfaces, leaving code we don’t want to deal with outside our system. We can Read more…

Gil Zilberfeld explains refactoring for legacy code, about method extraction and constructor injection for refactoring legacy code

Refactoring Kung Fu: Part III

Check out the original version of the code (Java, and also in C#, in tag 1.0). Right, time to move some code around. Before we do that, remember step #1 in our process: Draw a line around our tested code. For us it’s mainly the “cook” method. That’s the heart Read more…