News Feed
Jobs Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sameer Borate's Blog:
Refactoring 3 Replace Temp with Query
June 08, 2009 @ 11:18:47

Continuing on in his refactoring series (part 1 & part 2) Sameer has posted part three - a method of replacing temporary variables with calls to other methods.

Temporary variables are a integral part of any code. But a splattering of the same all over can make your code hard to understand or modify. Replace temp with query is a refactoring method where you replace temp variable expressions with methods. This method is often also required before you use the Extract Method refactoring.

In his example, he takes a variable inside a current method (base_price) and replaces it with a method call by the same name resulting in a more reusable format other methods can call rather than just computing the value themselves.

0 comments voice your opinion now!
method variable temporary refactor


blog comments powered by Disqus

Similar Posts

Dave Marshall's Blog: Log memory usage using declare and ticks in PHP

Brandon Savage's Blog: Keeping Superglobals Out Of Classes

Matthew Weier O'Phinney: ZF2's New Controller::init()

Sameer Borate's Blog: Refactoring 2: Extract Method

Content With Style: buggy behaviour of parent:: in PHP 5.3.3


Community Events











Don't see your event here?
Let us know!


unittest series symfony2 introduction overview package hhvm hack podcast security opinion release component language application facebook composer install code framework

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework