PHP

  • submit to reddit

Practical PHP Refactoring: Encapsulate Downcast (and Wrapping)

In statically typed languages, each variable must have a minimal type known at compile time. PHP instead, a is dynamic language where variable can contain any...

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

Practical PHP Refactoring: Replace Constructor with Factory Method

In the scenario of today, we have a complex constructor: read this definition as anything that does more work than assigning parameters to fields.The solution...

0 replies - 4575 views - 12/12/11 by Giorgio Sironi in Articles

Practical PHP Refactoring: Hide Method

In the scenario we address today, a method is not used from outside a class, or it's called only from a limited set of classes, such as the current inheritance...

0 replies - 3125 views - 12/08/11 by Giorgio Sironi in Articles

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 - 3382 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 - 3142 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

Selenium 2 from PHP code

Selenium 2, the new iteration of the end-to-end web application testing tool, contains some fancy innovations over its 1.x version: it controls browser...

4 replies - 13911 views - 11/15/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 - 3262 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 - 3088 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 - 2813 views - 11/07/11 by Giorgio Sironi 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 - 3832 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 - 4312 views - 10/26/11 by Giorgio Sironi in Articles