refactoring

Recursos de programación de refactoring
January- Software Architecture for Developers, Simon Brown - Functional Programming Patterns in Scala and Clojure, Michael Bevilacqua-Linn- Working Effectively with Unit Tests, Jay FieldsFebruary- Vida y Destino (Жизнь и судьба), Vasili Grossman. (2nd time)- Primer Libro de Lankhmar (The First Book of Lankhmar), Fritz Leiber- Drown, Junot Díaz- Los girasoles ciegos, Alberto Méndez- Smalltalk Best Practice Patterns, Kent BeckMarch- Las puertas del paraiso (The Vagrants), Yiyun Li- Growing Object-...
After the two previous posts (Clarifying conditional logic and Replacing conditional with polymorphism using multimethods), I had this version of the code: that was being used from the gilded-rose.core name space: Then I started introducing the new conjured items functionality using TDD. These are the new tests for conjured items: and these is the resulting code of the gilded-rose.item-quality name space: Notice the change in the update multimethod dispatch function. Now instead of being :name...
At the end of the previous post (Clarifying conditional logic), I had this version of the code: Even though the conditional logic in the update-item-quality function read much better than the original one, I completely got rid of it using the replace conditional with polymorphism refactoring. I used multimethods which is one of the ways of achieving polymorphism in Clojure. To start this refactoring, I first renamed the update-item-quality function to update-item-quality-old. Then I created a m...
Yesterday I did the Gilded Rose refactoring kata in Clojure which I started working on in the last Clojure Developers Barcelona meetup. This is the original code that I got from a Mike Jansen's GitHub repository: First of all I wrote tests following the description of the kata and had to fix several bugs related with items quality inferior and superior limits, 0 and 50 respectively. These are the tests using Midje: Once all the tests were in place, I started the refactoring by improving the in...
Another problem I found while working on a legacy Angular application last year, was huge controllers with several hundreds of lines. Most of those controllers contained a lot of procedural code and were doing too much. This made them very hard to test. In the new Angular application we're currently working on, we're refactoring very aggressively to keep the size of our controllers small. Apart from the strategy I talked about in a previous post, another technique that is giving us good results...
One of the problems I found while working on a legacy Angular application last year, was resources with deeply nested structures that were being accessed directly from many different places. That code was revealing too much about the resources inner structure and that meant that the code that interacted with the resources was spread all over therefore generating a lot of duplication. That made it really hard to change and understand. It was suffering from a severe case of primitive obsession in...