The point of OO PHP

K

Keith Bowes

Berislav said:
Although OOP is a great way to program and especially to keep your code and
design neat and easy to update, I still see PHP as a procedure-oriented
language, and don't see what is to be gained by introducing the plethora of
OOP features. I mean, PHP is (primarily) used for server-client HTTP-based
applications, where on each HTTP request the script is evaluated, parsed and
performed again. Even if we put all our code into a single PHP file (which
is a common practice) and the code is cached to speed things up, we still
have a blank slate each time the file is called, and we have to resend all
the values.

Well, PHP is still useful for shell, command-line and GUI scripting
(it's a lot easier than Perl). Though, even though most scripts are
small and hidden, maybe those that want it have a bad feeling when not
OOPing. Also, PHP 4 has a half-baked OO-system, so the least that PHP 5
can do is fully bake it (removing it altogether wouldn't be an option,
especially because of PEAR).

As for my personal opinion, I don't care too much for OOP. I mean that
I don't mind using OO libs, but I never catch myself actually making
objects. I really don't see how it's better than procedural (maybe this
is due to my BASIC background).
 
B

Berislav Lopac

I have a some experience in OOP, primarily with Java and JavaScript, and a
little with PHP4. I have just checked some texts about upcoming PHP5
features, and particularly the OOP ones, and there is something that puzzles
me.

Although OOP is a great way to program and especially to keep your code and
design neat and easy to update, I still see PHP as a procedure-oriented
language, and don't see what is to be gained by introducing the plethora of
OOP features. I mean, PHP is (primarily) used for server-client HTTP-based
applications, where on each HTTP request the script is evaluated, parsed and
performed again. Even if we put all our code into a single PHP file (which
is a common practice) and the code is cached to speed things up, we still
have a blank slate each time the file is called, and we have to resend all
the values.

In my opinion, one of the points of OOD is to have a bunch of objects which,
once constructed, exist in some sort of "virtual reality" and interact with
each other, sending each other messages and changing each other's states.
Web's architecture is not the perfect environment for this approach, but it
can be done the way it is with JSP, where we can have persistent JavaBeans,
which interact with HTTP requests as if they were other objects.

I might have misunderstood the concepts behing PHP5 and Zend Engine 2, but I
don't see buch point in OOP approach if an object exists only while a script
is being executed. I would like to hear any clarifications, as well as other
people's others opinions on that subject.

Best regards,

Berislav
 
R

Randell D.

Berislav Lopac said:
I have a some experience in OOP, primarily with Java and JavaScript, and a
little with PHP4. I have just checked some texts about upcoming PHP5
features, and particularly the OOP ones, and there is something that puzzles
me.

Although OOP is a great way to program and especially to keep your code and
design neat and easy to update, I still see PHP as a procedure-oriented
language, and don't see what is to be gained by introducing the plethora of
OOP features. I mean, PHP is (primarily) used for server-client HTTP-based
applications, where on each HTTP request the script is evaluated, parsed and
performed again. Even if we put all our code into a single PHP file (which
is a common practice) and the code is cached to speed things up, we still
have a blank slate each time the file is called, and we have to resend all
the values.

In my opinion, one of the points of OOD is to have a bunch of objects which,
once constructed, exist in some sort of "virtual reality" and interact with
each other, sending each other messages and changing each other's states.
Web's architecture is not the perfect environment for this approach, but it
can be done the way it is with JSP, where we can have persistent JavaBeans,
which interact with HTTP requests as if they were other objects.

I might have misunderstood the concepts behing PHP5 and Zend Engine 2, but I
don't see buch point in OOP approach if an object exists only while a script
is being executed. I would like to hear any clarifications, as well as other
people's others opinions on that subject.

Best regards,

Berislav

I'm curious why you did't post this to comp.lang.php... or at very least,
cross post it there...
 
B

Berislav Lopac

Randell said:
I'm curious why you did't post this to comp.lang.php... or at very
least, cross post it there...

Because I mixed it up. Sorry.

Berislav
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top