
In the scenario of today, an if chooses to execute different behavior depending on the type of an object. We should define "type" very looosely; for...
0 replies - 4157 views - 10/24/11 by Giorgio Sironi in Articles

We agree that polymorphism eliminates many cases where if() statements are necessary. However, if we have a tangled conditional, it's better to simplify it as...
0 replies - 3111 views - 10/19/11 by Giorgio Sironi in Articles

Control flags are boolean variables used to determine if you should stop a cycle or go on for another iteration. Since iteration is one of the three basic...
0 replies - 2968 views - 10/17/11 by Giorgio Sironi in Articles

A piece of code is contained in all legs of a conditional: an obvious solution is to move it outside to simplify the branches. It may seem stupid to come up...
0 replies - 2582 views - 10/12/11 by Giorgio Sironi in Articles

In this new article we continue to tackle conditional expressions, and their evolution towards polymorphism.In the scenario of today, multiple conditions lead...
0 replies - 2733 views - 10/10/11 by Giorgio Sironi in Articles

Michael Feathers presented his recurring idea of finding out which elements of design change together: his goal is to discover which classes or methods are...
0 replies - 5058 views - 10/06/11 by Giorgio Sironi in Articles

The terminology we will use in these articles on conditionals will be the following:a conditional is a whole if/else or switch statement and its content. It is...
0 replies - 3658 views - 10/05/11 by Giorgio Sironi in Articles

Sometimes a refactoring that start from type codes take the inverse direction.One common case is when a hierarchy of subclasses presents variations only in...
0 replies - 3564 views - 10/03/11 by Giorgio Sironi in Articles

This article is the third and last part of the refactoring from type codes miniseries.First, we saw a case where no behavior was modified by the type code...
0 replies - 4780 views - 09/28/11 by Giorgio Sironi in Articles

This is the second part in the refactoring from type codes miniseries: type codes are scalar fields that can assume a finite number of values. The assumption...
0 replies - 4580 views - 09/26/11 by Giorgio Sironi in Articles

The scenario of today will be familiar to many developers which have experience with ENUM database fields: it consists in a numerical or fixed string type code...
0 replies - 4563 views - 09/21/11 by Giorgio Sironi in Articles

We often find ourselves tempted by the shortcut of using directly a record-like data structure provided by the language or a framework. There are many example...
1 replies - 4488 views - 09/19/11 by Giorgio Sironi in Articles

In the scenario of today, a method returns an array (or a collection object) kept as a field on the object, or allows it to be set with a brand new...
0 replies - 4508 views - 09/14/11 by Giorgio Sironi in Articles

The public field has been abandoned in modern OOP for a return to the origins (although the getter/setter by default solution is not much better.) An object...
0 replies - 3963 views - 09/12/11 by Giorgio Sironi in Articles

In the scenario of today, we have a literal number, such as 42, scattered across the code base. Alternatively, this number may be just written in a single...
0 replies - 4641 views - 09/07/11 by Giorgio Sironi in Articles