tedd wrote:
function customer($whatWas, $customertype, $whatAdditional)
   {
   /* do "what was" (i.e., common to all) */
   /* then do what's additional unique to type */
   switch(1)
       {
       case $customertype =='Commercial':
       commercialCustomer($whatAdditional);
       break;

.. and so on
   }

function commercialCustomer($whatAdditional)
   {
   /*
   *only code unique to commercial customers
    */
   }

function militaryCustomer($whatAdditional)
   {
   /*
   *only code unique to military customers
   */
   }

In either case, I still have to write more code to accommodate scaling. And, if I have more customer types, then it's a simple matter to add more customer functions and addition case statements to the initial customer function. I don't see the benefit in using a class. At this point, it just looks like a different way of doing things.

You can limit the need to add more code like so...

function customer($whatWas, $customertype, $whatAdditional)
{
    /* do "what was" (i.e., common to all) */
    /* then do what's additional unique to type */
    $func = strtolower($customertype).'Customer';
    $func($whatAdditional);
}

You could do (and I have done) something similar with classes.

For me the biggest benefit of using OOP is __autoload(). It makes life so much easier.

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to