
Suppose you have a God class that is full of ifs and case statements, or boolean flags. Many refactorings try to segregate responsibilities in smaller...
0 replies - 4625 views - 02/15/12 by Giorgio Sironi in Articles

PHP is unfortunately famous for spaghetti code, but instances of tangle logic is a product of the programmer and not of the language.One of the anti-patterns...
0 replies - 4303 views - 02/13/12 by Giorgio Sironi in Articles

Even in languages where there are no constructs but classes, there is no constraint that can force a programmer into writing object-oriented code. In many...
0 replies - 5166 views - 02/08/12 by Giorgio Sironi in Articles

We are entering into the final part of this series, on large scale refactorings: this kind of operations is less predictable and less immediate. However, it is...
0 replies - 3124 views - 02/06/12 by Giorgio Sironi in Articles

Delegation is a more flexible solution with respect to inheritance, because it allows to change collaborators by introducing new classes. However, it hides the...
0 replies - 3911 views - 02/01/12 by Giorgio Sironi in Articles

When a subclass violates the Liskov Substitution Principle, or uses only part of a superclass, it is a warning sign that composition can simplify the...
0 replies - 4685 views - 01/30/12 by Giorgio Sironi in Articles

Duplication is not always expressed as an identical block of code: often it is subtler to discover, because it exists at an higher level of...
2 replies - 4492 views - 01/25/12 by Giorgio Sironi in Articles

In the scenario of today, a subclass and superclass are not very different: the evolution of the code has brought them to this situation. Behavior has been...
0 replies - 2998 views - 01/23/12 by Giorgio Sironi in Articles

A concrete class still defines an implicit interface by itself, as the set of its public methods. When the called interface is a subset of this, or it is...
1 replies - 3132 views - 01/18/12 by Giorgio Sironi in Articles

In the scenario of today, there are two or more unrelated classes with similar members, like common methods or fields. While these classes may be already...
0 replies - 3092 views - 01/16/12 by Giorgio Sironi in Articles

So far, we have only treated the movement of object members (fields and methods, and constructor as special methods); the assumption we made was that these...
0 replies - 2981 views - 01/11/12 by Giorgio Sironi in Articles

As happens often for a method, a field may be present in the base class of a hierarchy even if it is actually used only in some of the subclasses. This...
0 replies - 2655 views - 01/09/12 by Giorgio Sironi in Articles

In the scenario of today, some logic is in a superclass of a hierarchy, modelled as a method. However, this method is only useful for one of the subclasses in...
0 replies - 2586 views - 01/04/12 by Giorgio Sironi in Articles

After Pull Up Field and Pull Up Method, we explore today the last of this category of refactorings: Pull Up Constructor Body.The scenario consists of a series...
0 replies - 2962 views - 01/02/12 by Giorgio Sironi in Articles

We are in the part of the series where refactorings target mostly the elimination of duplicated code. For now, most solutions will achieve this goal via...
0 replies - 2973 views - 12/28/11 by Giorgio Sironi in Articles