Connecting Tech Pros Worldwide Forums | Help | Site Map

The point of OO PHP

Berislav Lopac
Guest
 
Posts: n/a
#1: Jul 20 '05
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



Keith Bowes
Guest
 
Posts: n/a
#2: Jul 20 '05

re: The point of OO PHP


Berislav Lopac wrote:[color=blue]
>
> 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.[/color]

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).

Randell D.
Guest
 
Posts: n/a
#3: Jul 20 '05

re: The point of OO PHP



"Berislav Lopac" <berislav.lopac@dimedia.hr> wrote in message
news:bu11kv$bu$1@ls219.htnet.hr...[color=blue]
> 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[/color]
puzzles[color=blue]
> me.
>
> Although OOP is a great way to program and especially to keep your code[/color]
and[color=blue]
> 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[/color]
of[color=blue]
> OOP features. I mean, PHP is (primarily) used for server-client HTTP-based
> applications, where on each HTTP request the script is evaluated, parsed[/color]
and[color=blue]
> 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[/color]
which,[color=blue]
> once constructed, exist in some sort of "virtual reality" and interact[/color]
with[color=blue]
> each other, sending each other messages and changing each other's states.
> Web's architecture is not the perfect environment for this approach, but[/color]
it[color=blue]
> can be done the way it is with JSP, where we can have persistent[/color]
JavaBeans,[color=blue]
> which interact with HTTP requests as if they were other objects.
>
> I might have misunderstood the concepts behing PHP5 and Zend Engine 2, but[/color]
I[color=blue]
> don't see buch point in OOP approach if an object exists only while a[/color]
script[color=blue]
> is being executed. I would like to hear any clarifications, as well as[/color]
other[color=blue]
> people's others opinions on that subject.
>
> Best regards,
>
> Berislav
>[/color]

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


Berislav Lopac
Guest
 
Posts: n/a
#4: Jul 20 '05

re: The point of OO PHP


Randell D. wrote:[color=blue]
> I'm curious why you did't post this to comp.lang.php... or at very
> least, cross post it there...[/color]

Because I mixed it up. Sorry.

Berislav


Closed Thread


Similar JavaScript / Ajax / DHTML bytes