[development] the time of $op is over?

Larry Garfield larry at garfieldtech.com
Tue May 13 15:55:52 UTC 2008


On Tue, 13 May 2008 22:55:08 +1000, Gordon Heydon <gordon at heydon.com.au> wrote:
> Hi,
> 
> On 13/05/2008, at 10:01 PM, Earnie Boyd wrote:
> 
>> Quoting David Timothy Strauss <david at fourkitchens.com>:
>>
>>> * A long series of cases is often justification for reconsidering
>>> the program structure, like we are right now with $op.
>>>
>>
>> You don't have to use a switch statement now nor long complicated if/
>> elseif/else statements either.
>>
>> <?php
>> $func = '_mymodule_func_' . $op;
>> if (function_exists($func)) {
>> $ret = call_user_func_array($func, $args);
>> }
>> ?>
> 
> Yes this is good, and make the code simplier. I actually removed $op
> from e-Commerce where ever I found it.
> 
> Tidied things up very well.
> 
> Gordon.

Agreed.  My code is littered with dynamic subcalls like that for everything from eliminating op to having a per-node-type preprocess function.  It makes the code far easier to follow and maintain.  Building that or something like it straight into most subsystems is a good thing.

--Larry Garfield



More information about the development mailing list