News Feed
Jobs Feed
Sections

Recent Jobs

News Archive
Tim Koschuetzki's Blog:
Composing Methods Remove Assignments to Parameters
July 06, 2007 @ 10:21:00

In another part of his "Composing Methods" series, Tim Koschuetzki posts about removing assignments to parameters today - working with a temporary variable inside a method rather than the actual passed in value.

When your code assigns to a parameter in a function/method, use a temporary variable instead. [...] It will make your code much more readable and prevents by-reference confusion and therefore big problems in the future.

His example code uses the illustration of calling a price() method in a class to modify the inputVal value based on other inputted information. His suggestion is to not work with the actual inputVal value passed in (so as to avoid issues if it happens to be passed my reference later), but to work with a temporary variable - $result - inside the method.

0 comments voice your opinion now!
method compose remove assignment parameter temporary variable method compose remove assignment parameter temporary variable



Similar Posts

Matthew Weir O'Phinney's Blog: PHP 5's Reflection API

Brian Moon's Blog: You have to be really smart to code PHP!

Paul Jones' Blog: Solar Views and Layouts

Christopher Jones' Blog: When a few seconds are important: improving PHP Oracle connection speed

Matthew Turland's Blog: Pondering PHP 6


Community Events







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


example job conference code security database developer package mysql release PHP5 zendframework framework zend book application cakephp PEAR releases ajax

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