Re: All-in-one PHP Classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



# dmagick@xxxxxxxxx / 2007-02-08 11:27:13 +1100:
> Roman Neuhauser wrote:
> ># dmagick@xxxxxxxxx / 2007-02-07 09:59:15 +1100:
> >>Roman Neuhauser wrote:
> >>># user@xxxxxxxxxxxxx / 2007-02-06 12:47:47 +0100:
> >>>>Have been reading posts daily for two months now on the list, and
> >>>>am very pleased at how informative these can be.  I have noticed,
> >>>>many examples where one is pointed to using classes downloadable
> >>>>on the internet.  This is when i realized how often these classes
> >>>>that do "everything" are very BIG.
> >>>Big classes and long methods are signs of bad code, no matter if it's
> >>>downloadable for free or costs money.
> >>Pfft. Depends on the code.
> >>
> >>A developer api is going to have long methods / functions, simply 
> >>because of error checking.
> >
> >Could you give me an example?
> 
> Anything based on PEAR.
> 
> I was going to point to 
> http://pear.php.net/package/MDB2/docs/2.3.0/__filesource/fsource_MDB2__MDB2-2.3.0MDB2.php.html 
> which has 4,000 lines of code in one file, but then I realised it has 
> multiple classes in the same file (which is usually a no-no as well).

I had a quick glance at the file to see what the code looks like, and
immediately spotted this:

290    function setOptions(&$db, $options)
291    {
292        if (is_array($options)) {
293            foreach ($options as $option => $value) {
294                $test = $db->setOption($option, $value);
295                if (PEAR::isError($test)) {
296                    return $test;
297                }
298            }
299        }
300        return MDB2_OK;
301    }

The code is careful to not provoke a warning, but returns MDB2_OK if you
screw up and give it a wrong type of value.  It's long and has a bug.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux