Forum Moderators: coopster
From what I understand the PHP OOP model is not great in pre 5 versions of PHP.
It's always been my aim to move towards OOP in PHP as I've seen some excellent examples of what can be achieved. When 5 has had time to mature I think I'll give it a go.
I would not say OOP PHP is bad, but it definitely is not as robust or as flexible as Java is. The basics of OOP PHP are there: objects, classes, and method which is what most people use anyway.
It would be nice when PHP will start supporting more Java related OOP concepts like method overloading, automatic garbage collection.
I am trying to make it like Java where Java is smart enough to look in the web directory for an external java class. Since PHP cannot do this, I am making class files and then using include_once commands to import them.
It seems to be working well for me.
Use it all of the time. The trouble with OO is that to use it most effectively it is a real shift in thinking. What I have found in teaching OO practices is that people find the initial concepts (polymorphism, encapsulation, inheritance) very easy. Then they start writing more than a trivial project and hit a massive brick wall :(. OO gives you a bewildering array of choices as to how to cut an application.
Say you want to book a hotel room. You can do...
$room->book($person); $person->book($room); $booking = &$room->reserve($person); It all depends on context of course. Here is a road map of what you are walking into:
1) Easy this object stuff. I know it already. :)
2) Don't see much advantage over functions. Objects are just packages. :(
3) Help. I know nothing. What are these patterns things? Why don't I get this? :(
4) Refactoring. Hey I can fix mistakes really easily. :o
5) The interface is king. Implementation - who cares? :o
6) Design patterns (decorator, iterator, visitor). :)
7) Unit testing. Hey, no debugging any more! :)
8) I cannot believe I was daft enough to program any other way. :o
It's a two year plus journey, but you will never want to go back.
yours, Marcus