PowWeb Forums - The Perfect Community for the Perfect Host  

Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more.

Go Back   PowWeb Community Forums > The PowWeb Platform > PHP
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Closed Thread
 
Thread Tools
Old 9-5-03, 05:59 AM   #1
PHPGuru
Guest
 
Posts: n/a
OOP vs. PP in PHP

Are there any better benefits of writing PHP script with OOP
(Object Oriented Programming) than PP (Procedual Programming)??

I understand the general benefits of OOP, but PHP is a
scripting language like Perl, so it is interpreted by the PHP
interpreter and then executed line by line, so what's the good
use of classes if the script is not compiled before it is deployed
like Java?? Instead of writing classes, you can just write
functions in one file and it can be included in other pages.

Any comments??
 
Old 9-5-03, 09:17 AM   #2
HalfaBee
 
HalfaBee's Avatar
 
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 7,266
Reputation: 340
It allows you to write classes that could be used in other php scripts.

Halfabee
__________________
I don't suffer from laziness, I enjoy every minute!
Edit your php.ini here
http://members.powweb.com/member/cgi...nt/PHPplus.bml
HalfaBee is offline  
Old 9-5-03, 08:22 PM   #3
Mirzabah
mod_rewrite
 
Mirzabah's Avatar
 
Join Date: Apr 2002
Location: Melbourne, Australia
Posts: 2,038
Reputation: 166
Being interpreted rather than compiled doesn't make OO less useful. The key benefit of OO is structural. Basically it is a better way of organising code.

Cheers,
Mirzabah.
Mirzabah is offline  
Old 9-6-03, 01:41 AM   #4
Atomic-Design
Electro-shock Blues
 
Atomic-Design's Avatar
 
Join Date: Mar 2002
Location: Colorado
Posts: 1,878
Reputation: 5
OOP is just a code reuse concept. It's great for maximizing code reuse, so pages load faster, easier to make changes to everything ETC. I usually use it for a MUCH more power version of SSI's.

Functions work too... but functions don't handle Polymorphism or any advanced concepts.
__________________
If I lay my head down I will see you in my dream,
Wearing that polka-dot dress, and sitting by the stream.
Leaning in to hear you, you will whisper in my ear.
And everything I need to know, I finally hear.

When I was a baby we would go out to the park,
And sit out in the fountain, splashing 'round until its dark.
The days on forever when you only know that much,
And everything I need to know is answered with one touch.
Atomic-Design is offline  
Old 9-6-03, 09:39 PM   #5
Mirzabah
mod_rewrite
 
Mirzabah's Avatar
 
Join Date: Apr 2002
Location: Melbourne, Australia
Posts: 2,038
Reputation: 166
Quote:
Originally posted by Atomic-Design
OOP is just a code reuse concept...
Call me a pedant, but OOP is about modularity, not code reuse. However, improved code modularity does result in more reusable code.

It also leads to more maintainable code. If a code module is properly encapsulated, clients of the module can interact with it without having know anything about the internal implementation details of the module. This means that you can make all sorts of changes to the module without having to worry about how that is going to affect the rest of the program - so long as the interface to the module remains the same.

It is possible to write modular code in traditional procedural language, but it does require discipline. Procedural languages aren't 'naturally' modular and knowledge of module implementation tends to 'leak'.

Writing properly encapsulated modules is far more natural with OOP ... however you can still create an unholy mess if you ignore basic principles of OOP and structured programming. OOP won't make anyone into a good programmer, but it does make life easier for those of us that already are

PHP's OOP support is very limited when you compare it to Python, Java, C++, C# or even Visual Basic, but you can still use it to good effect.

Cheers,
Mirzabah.
Mirzabah is offline  
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:22 AM.


Contents ©PowWeb, Inc. ~ vBulletin, Copyright 2000-2007 Jelsoft Enterprises Limited.