
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 - 4535 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 - 3045 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 - 3203 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 - 3129 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 - 3021 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 - 2696 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 - 2637 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 - 3000 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 - 3007 views - 12/28/11 by Giorgio Sironi in Articles

We now enter in the territory of generalizations. It's a natural process, as we add more and more tests, for our code to become more general; but after we have...
0 replies - 4194 views - 12/26/11 by Giorgio Sironi in Articles

Sometimes catching an exception can be transformed in a preliminary check that avoid raising the exception in the first place. The code is then called only in...
0 replies - 2865 views - 12/21/11 by Giorgio Sironi in Articles

Error codes are mostly a relic of procedural programming: the object-oriented paradigm has introduced exceptions as a first-class mechanism to separate error...
2 replies - 3873 views - 12/19/11 by Giorgio Sironi in Articles

In statically typed languages, each variable must have a minimal type known at compile time. PHP instead, a is dynamic language where variable can contain any...
0 replies - 3360 views - 12/14/11 by Giorgio Sironi in Articles

In the scenario of today, we have a complex constructor: read this definition as anything that does more work than assigning parameters to fields.The solution...
0 replies - 4692 views - 12/12/11 by Giorgio Sironi in Articles

In the scenario we address today, a method is not used from outside a class, or it's called only from a limited set of classes, such as the current inheritance...
0 replies - 3177 views - 12/08/11 by Giorgio Sironi in Articles