refactoring

Recursos de programación de refactoring
I've just made a small TDD kata in C++ using GoogleMock.I committed the existing code after each green and after each refactoring step.Check the step by step process in GitHub. - por Garajeando
I've recently coded a solution to the StringCalculator kata in C++ using GoogleMock, (you can check its code in GitHub).In one of the refactoring steps, I extracted the code that filters out not numeric tokens to a separated helper method: filterOutNotNumericTokens:Once all the kata requirements were satisfied, I refactored this method a little bit more using C++11 copy_if algorithm:We can use the same technique to refactor the method that ignores numbers greater than 1000, ignoreTooBig, from th...
I've just made a small refactoring kata in C++.Some of the tests in the initial code* were very slow because their code had to sleep some time in order for them to pass. Some other tests relied on having certain environment variable set to a given value.The behavior that checked the environment variable and the one related to time were embedded in the Course class.Through refactoring this behavior was isolated and extracted so that it could be injected into Course and then two fake classes were...
Last Monday I hosted an event for Barcelona Software Craftsmanship community. We practiced refactoring and learned about ports and adapters using Matteo Vaccari's Birthday Greetings kata in refactoring mode. This is the initial code in Java that we tried to refactor.I prepared several slides to introduce what we were going to do. I thought that we could just start refactoring for two hours right after this explanation, but, thanks to the suggestions of some attendees, we changed the plan and did...
I've been playing a bit more with scopes to make the generalized version of FizzBuzz using Array.map and Array.join I posted about recently accept substitution rules with any predicate on a number. I also coded a factory function that creates the substitute function.This is the factory that creates a substitute function given a list of substitution descriptions objects which are composed of a predicate on the number and a replacement for the number:Next you can see how this factory is used in th...
I've just refactored the generalized version of FizzBuzz I posted about recently using Array.map and Array.join functions.This is the version that I had before:and this is the new version using Array.map and Array.join:Even though it was fun coding that "map+join" recursive function of the first version, the second version is much simpler and more efficient (I used jsPerf to compare the two versions, check out the comparison). Had I known Array.map and Array.join before, I could have saved a lot...
Last December I attended the Global Day of Code Retreat in Valencia. It was a lot of fun and we thought and discussed a lot about the problem. Thanks to all the participants and the organizers for the great time.When I came back to Barcelona I decided to go on practicing by developing a full solution to Conway's Game of Life on my own.I wanted the solution to include several of the ideas that we had been discussing during the code retreat:Tracking only living cells. Open/Closed with regard...
En esta charla práctica se presentará un pequeño proyecto hecho en Symfony2, totalmente funcional aunque con algunas cosas por mejorar. Primero se crearán algunos tests, que servirán para comprobar que la aplicación sigue funcionando después de cada refactorización. Después, se irá refactorizando el código paso a paso, explicando primero el patrón y después aplicándolo al código.
Interesante la reflexión que Martin Fowler realiza en su libro “Refactoring: Improving the Design of Existing Code” (traducción libre): “Al compilador no le preocupa que el código sea feo o limpio. Pero cuando cambiamos el sistema, hay una persona involucrada y ahí sí que importa. Un sistema mal diseñado es complicado de modificar”. En última …Leer Más - por Jummp