07-28-2002, 11:29 PM
Here's a link to a short article on object oriented programming and PHP you might find helpful. Good luck ;).
07-29-2002, 02:50 AM
How common for the average script/scripter... not very, though that may just mean that most are not used to or comfortable with OOP.
I have always been of the opinion that OOP for most web-related scripts is OverTheTop and rarely offers an advantage.
But the larger or more complex the project (and especially where you have some form of collaberation between several scripters) I think that the overhead of OOP begins to be quickly negated by the ease of use and modularity that OOP offers.
I have for instance found myself working on projects written by others several times, on the occaisions where the project was largely OO based I found it easier (after the initial groan) to work out how the beast actually worked and altering the logic of the applicaction was not as painful as originally expected.
What I cant stand are classes for the sake of it, classes for creating HTML tables or mysql connection routines (unless abstraction is required) etc I feel are a total waste of time and resources (unless as a method of some existing uber-class of some sort)
Check out http://pear.php.net which despite having a carp site and some definately questionable classes (check out the ImageMagick class) is supposed to be and perhaps one day will be a repository of classes that you may expect to find available on any PHP installation.
A note though, PHP$next_major_version is going to have some OOP functionality that is currently missing, destructors etc, so whilst PHP itself will probably be backwards compatible - I would expect a lot of the PEAR stuff to be rewritten and the classes themselves may act differently??
but yes you can do it all with functions as well :)
07-29-2002, 04:56 AM
OOP is your friend. :) I'm all about OOP being a Java programmer first. PHP still has some improvements to make when it comes to OOP but it's still a good idea.
Thanks guys, especially firepages. I guess OOP in PHP is confronted with the same dilemmas that exists in other web programming languages. The line between "showing off" and when you actually need to use OOP is often confusing for novices.
07-29-2002, 05:30 PM
As firepages has already pointed out, OOP in PHP takes some more time initially to design/code it, but maintenance and enhancements are much more easier from them on. Plus that I find OOP code much easier to document, and with phpdoc there also some assisting devices ready to employ for generating documentation.
What I find great about OOP in PHP is the possibility to encapsulate your variables, so that you don't have to clutter up your script's global scope with a multitude of global variables... can get quite confusing when a lot of developers add their own share of global variables through included files and makes the whole thingy difficult to debug.
Anyway, I would advice beginners to focus more on the other programming aspects of PHP and to get a firm grip of the most common functions, and then move on to class-based programming... first learn to walk, then to run.
just my $money::getCents(2);