refactoring

  • submit to reddit

Practical PHP Refactoring: Remove Setting Method

A setter for a certain field is present: maybe it's a generated method, or is used for Dependency Injection.However, in the current state of the code, there...

5 replies - 3383 views - 12/06/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Introduce Parameter Object

In the scenario of today, two or more parameters are often passed together to a set of similar methods. This happens for example with timing information...

0 replies - 3600 views - 11/30/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Replace Parameter with Method

An object Client invokes a method M1, or produces a value in some equivalent way. Then, it passes the result to a new method M2 on the object Server. However,...

0 replies - 3008 views - 11/28/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Preserve Whole Object

In the scenario of today, we are extracting some fields or calculated values from an object, and then calling a method somewhere else by passing them in as...

0 replies - 3383 views - 11/23/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Replace Parameter with Explicit Methods

The refactoring of today breaks up a method into multiple ones: it chops the method in pieces according to the code that is executed in response to one of the...

0 replies - 3144 views - 11/21/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Parameterize Method

In the scenario of today, multiple methods executs mostly the same logic: you can see a strong duplication of code between them, or identical delegation...

0 replies - 2902 views - 11/16/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Separate Query from Modifier

In the (recurring) scenario of today, a method modifies the state of an object and returns something at the same time. In this case, the method is an hybrid...

0 replies - 3263 views - 11/14/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Remove Parameter

As Kent Beck says, all refactoring techniques are bidirectional; in the case of add and remove refactorings, one direction increases the moving parts to face...

0 replies - 3089 views - 11/09/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Add Parameter

In the scenario of today, a method is missing some information to accomplish its responsibility. Usually, it is forced to look up these data into some form of...

0 replies - 2814 views - 11/07/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Rename Method

Renaming a method, without changing its signature, is a not expensive operation and can give you a great benefit while reasoning about code. Just a change from...

0 replies - 3146 views - 11/02/11 by Giorgio Sironi in Articles

Opportunistic Refactoring by Martin Fowler

From the very beginning of when I started to talk and write about refactoring people have asked me how it should be incorporated into the wider software...

0 replies - 9917 views - 11/01/11 by Martin Fowler in Articles

Practical PHP Refactoring: Introduce Assertion

A portion of code makes an assumption about something: the current state of the object, or of the parameter, or of a local variable of the cycle. Normally this...

0 replies - 3835 views - 10/31/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Introduce Null Object

In the scenario of today, we see repeated checks for an object's equality to null, false or another scalar value without behavior. These checks take a form...

0 replies - 4314 views - 10/26/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Replace Conditional with Polymorphism

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

Tell, Don't Ask in the case of a web service

This is a language agnostic post: it is valid for each object-oriented imperative language like Java, C#, PHP. Let's start from the beginning: a web service...

8 replies - 6826 views - 10/20/11 by Giorgio Sironi in Articles