Forum Moderators: coopster

Message Too Old, No Replies

Object Oriented PHP.

Do you use it?

         

brucec

3:44 am on Mar 12, 2004 (gmt 0)

10+ Year Member



I started using object oriented PHP and I am starting to create all kinds of objects and classes with them.

Has anyone else dabbling in it?

carneddau

4:08 pm on Mar 12, 2004 (gmt 0)

10+ Year Member



I've used OOP in PHP a couple of times but the kind of projects I work on are generally pretty small and easier (for me anyway) to just throw together function libraries that I've accumulated over the years.

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.

brucec

5:52 pm on Mar 12, 2004 (gmt 0)

10+ Year Member



I like the OOP model for PHP now and I don't find a problem with it.

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.

jatar_k

7:20 pm on Mar 12, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



We use it a bit here and there.

I won't really consider it a staple until I see php 5 though.

brucec

2:47 am on Mar 13, 2004 (gmt 0)

10+ Year Member



I am starting to see good uses for it.

lastcraft

4:51 pm on Mar 14, 2004 (gmt 0)

10+ Year Member



Hi...

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

...or...
$person->book($room);

...or...
$booking = &$room->reserve($person);

Now which one to choose?

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