> Say I have a database class with all kinds of functions for connection, 
> data manipulation, errors, etc:
> 
>  $db = new db_sql;
> $db->connect();
> $db->do_this();
> $db->do_that();
> 
> How would that be different from an include file with a bunch of functions 
> doing the same thing?

As far as I'm concerned, the primary benefit of classes is that you
don't clutter up your namespace. If you have, for instance, 
$accesses->count, you know more about that count than if you have 
just $count. It's a method of organizing your code that doesn't (once
you get used to it) get in the way.

Also, you can be really sure that $accesses->resetCounter() is somehow
related to $accesses->count, whereas $accesses_count and 
accesses_resetCounter() might win your confidence incorrectly. Or maybe
you slip and use access_resetCounter() instead, which might be the cause
of no end of grief.

(You know that $accesses->count and $accesses->resetCounter() are at
least declared in the same class declaration. $accesses_count and
accesses_resetCounter() could be declared in entirely unrelated include
files for entirely different purposes.)

> Is there any performance benefit one way or the other?

Programmer performance?

> I used EZ_Sql which is cool but didn't seem to speed things up in 
> comparison to the said include file.
> Still don't see the beef.

Execution speed isn't all that matters. In fact, speed is not the point
at all.

> Brad recommended I spend even more time with google looking for OOP, maybe 
> that's why I'm so confused:).

I think he's trying to point you to the mind-set. Do you like complex
puzzles with intricate interactions where you have to keep tens of
thousands of lines of code constantly in your head? Or do you like to
focus on several hundred lines at a time, get those to behave, then move
on to another part with a fairly high level of confidence that you won't
shoot yourself in the foot by using the wrong count or resetCount()
somewhere?

-- 
Joel Rees, programmer, Kansai Systems Group
Altech Corporation (Alpsgiken), Osaka, Japan
http://www.alpsgiken.co.jp


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

Reply via email to