
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 - 4133 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 - 3098 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 - 2953 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 - 2562 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 - 2720 views - 10/10/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 - 3648 views - 10/05/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 - 4771 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 - 4564 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 - 4536 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 - 4473 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 - 4487 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 - 3947 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 - 4631 views - 09/07/11 by Giorgio Sironi in Articles

This refactoring is the inverse of Change Unidirectional Association to Bidirectional. We start from a bidirectional association, where two objects reference...
0 replies - 4195 views - 09/05/11 by Giorgio Sironi in Articles

Object graphs are built by maintaining references to other objects inside an object's fields (usually private). These associations are persisted and stored by...
0 replies - 4382 views - 08/31/11 by Giorgio Sironi in Articles