473,411 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

The point of OO PHP

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
Jul 20 '05 #1
3 1250
Berislav Lopac wrote:

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

Jul 20 '05 #2

"Berislav Lopac" <be************@dimedia.hr> wrote in message
news:bu*********@ls219.htnet.hr...
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...
Jul 20 '05 #3
Randell D. wrote:
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
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

687
by: cody | last post by:
no this is no trollposting and please don't get it wrong but iam very curious why people still use C instead of other languages especially C++. i heard people say C++ is slower than C but i can't...
9
by: pout | last post by:
What are the purposes of fixed-point? When should it be used? I read: #define Int2Fixed(x) (((long)(short)x) << 16) and the fixed-point in 16.16 format. Does the 16 in the MACRO refer to...
65
by: Skybuck Flying | last post by:
Hi, I needed a method to determine if a point was on a line segment in 2D. So I googled for some help and so far I have evaluated two methods. The first method was only a formula, the second...
3
by: Action | last post by:
Point is a struct but I can do both Point a; Write(a.X); Write(a.Y); and Point a = new Point(1,1); Write(a.X);
1
by: Tamir Khason | last post by:
Somebody knows how to convert Bounds to Point ??? Thnx
3
by: Peter Proost | last post by:
Hi group, I've got this bit of code (see below) which draws a basketball field in a picturebox (width:198, height:368) but now I was wondering what would be the easiest way to check inside the...
39
by: DanielJohnson | last post by:
I wrote a simply program with a 3 D coordinate called point. I am adding two points, taking their distance etc. gcc compiler is not identifying the struct. Here is the code. I get bunch of errors....
39
by: rembremading | last post by:
Hi all! The following piece of code has (for me) completely unexpected behaviour. (I compile it with gcc-Version 4.0.3) Something goes wrong with the integer to float conversion. Maybe somebody...
1
by: Linda Liu[MSFT] | last post by:
Hi George, Thank you for posting! This is a quick note to let you know that I am doing research on this issue and will get back to you ASAP. I appreciate your patience! Sincerely,
0
by: raylopez99 | last post by:
I ran afoul of this Compiler error CS1612 recently, when trying to modify a Point, which I had made have a property. It's pointless to do this (initially it will compile, but you'll run into...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.