Results 1 to 5 of 5

Thread: OOP vs. PP in PHP

  1. #1
    PHPGuru
    Guest

    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??

  2. #2
    HalfaBee's Avatar
    Join Date
    Feb 2002
    Location
    Sydney, Australia
    Posts
    7,266
    Rep Power
    26
    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

  3. #3
    mod_rewrite Mirzabah's Avatar
    Join Date
    Apr 2002
    Location
    Melbourne, Australia
    Posts
    2,038
    Rep Power
    19
    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.

  4. #4
    Electro-shock Blues Atomic-Design's Avatar
    Join Date
    Mar 2002
    Location
    Colorado
    Posts
    1,878
    Rep Power
    17
    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.

  5. #5
    mod_rewrite Mirzabah's Avatar
    Join Date
    Apr 2002
    Location
    Melbourne, Australia
    Posts
    2,038
    Rep Power
    19
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •