[Phpwm] OO?
Iain Wallace
iain at strawp.net
Mon Dec 12 07:08:38 GMT 2005
Jono Bacon wrote:
> Hi all,
>
> I was wondering - how much does anyone actually use the OO
> functionality that is in PHP, particularly PHP5. Although I have done
> OO stuff before in C++, I find myself largely writing fairly
> procedurally in PHP, and only really using OO when using PEAR.
>
> What are your thoughts?
>
> Jono
>
I think it can actually be very useful for dealing with data models that
aren't necessarilly from a database. Obviously PHP has plenty of built
in database functions (and even the mysqli class if you want) to deal
with database access, so abstracting away a data access layer is pretty
pointless a lot of the time.
An example of where I've created a data access class in PHP is a project
I did last year as an interface for my TV tuner. I had a digital tuner
on a windows box which you could set to record via the command line. I
*could* have done all the scheduling and recording bits using countless
seperate instances of exec(), but it's much nicer to have one interface
class called Tuner and have Tuner->start_record() etc in it.
The scripts also took in TV listings to do the whole tivo-esque
programme guessing thing, so having Programme(), Channel(), Schedule()
etc instead of raw XML to have to manipulate made it much easier.
All the object-based web projects I've seen have had the tendency to be
dog-slow, however. If one can do it easily without using objects the I'd
go that route every time.
Cheers,
Iain
P.S. Isn't PHP5 actually object-based as opposed to object oriented?
Unless I've completely failed to spot that it can actually handle
polymorphism.
More information about the Phpwm
mailing list