PHP

  • submit to reddit

Practical PHP Refactoring: Tease Apart Inheritance

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 - 3122 views - 02/06/12 by Giorgio Sironi in Articles

Practical PHP Refactoring: Replace Delegation with Inheritance

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 - 3906 views - 02/01/12 by Giorgio Sironi in Articles

Practical PHP Refactoring: Replace Inheritance with Delegation

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 - 4676 views - 01/30/12 by Giorgio Sironi in Articles

Practical PHP Refactoring: Form Template Method

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 - 4490 views - 01/25/12 by Giorgio Sironi in Articles

Practical PHP Refactoring: Collapse Hierarchy

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 - 2997 views - 01/23/12 by Giorgio Sironi in Articles

Practical PHP Refactoring: Extract Interface

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 - 3126 views - 01/18/12 by Giorgio Sironi in Articles

Practical PHP Refactoring: Extract Superclass

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 - 3089 views - 01/16/12 by Giorgio Sironi in Articles

Practical PHP Refactoring: Extract Subclass

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 - 2980 views - 01/11/12 by Giorgio Sironi in Articles

Practical PHP Refactoring: Push Down Field

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

Practical PHP Refactoring: Push Down Method

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 - 2585 views - 01/04/12 by Giorgio Sironi in Articles

Practical PHP Refactoring: Pull Up Constructor Body

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 - 2959 views - 01/02/12 by Giorgio Sironi in Articles

Practical PHP Refactoring: Pull Up Method

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 - 2965 views - 12/28/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Pull Up Field

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 - 4109 views - 12/26/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Replace Exception with Test

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 - 2822 views - 12/21/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Replace Error Code with Exception

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 - 3800 views - 12/19/11 by Giorgio Sironi in Articles