refactoring

  • submit to reddit

Trying out PHP Refactoring Browser

Remember the times when they tried to convert you from your Unix-based PHP setup to an IDE, throwing away Vim and command line tools for Eclipse of...

0 replies - 1652 views - 04/15/13 by Giorgio Sironi in Articles

Transform switches in maps

This article is about a recurring pattern you can apply while encountering chain of conditionals or switch statements. Although their usage can be limited via...

0 replies - 4936 views - 08/29/12 by Giorgio Sironi in Articles

Fixing Bugs: The Ones That Can't be Reproduced

There are bugs that can’t be reproduced, or at least not easily: intermittent and transient errors; bugs that disappear when you try to look for them;...

0 replies - 4873 views - 08/21/12 by Jim Bird in Articles

Lean Tools: Refactoring

Refactoring is one of the basic tools in Agile development: it consists in changing the form of the code without changing its function. While refactoring, you...

0 replies - 3038 views - 08/01/12 by Giorgio Sironi in Articles

Is Copy and Paste Programming Really a Problem?

Copy and Paste Programming – taking a copy of existing code in your project and repurposing it – violates coding best practices like Don’t Repeat...

4 replies - 11380 views - 06/28/12 by Jim Bird in Articles

Testing PHP scripts

Let's see a common scenario: you want to refactor some legacy code (without any test), which may not even be object-oriented, into some discrete chunks that...

0 replies - 5932 views - 04/25/12 by Giorgio Sironi in Articles

Bullets for legacy code

The most common legacy code definition is that of a project not covered by automated tests: picture in your mind a big ball of mud, difficult to change or...

1 replies - 8852 views - 03/27/12 by Giorgio Sironi in Articles

Practical PHP Refactoring: Extract Hierarchy

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

Practical PHP Refactoring: Separate Domain from Presentation

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

Practical PHP Refactoring: Convert Procedural Design to Objects

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

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 - 3117 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 - 3902 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 - 4664 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 - 4476 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 - 2992 views - 01/23/12 by Giorgio Sironi in Articles