Re: Using a Resource as a Class Property



Sanders Kaufman wrote:
Toby A Inkster wrote:

So to correct my statement:

In OOP (not just PHP) the constructor of the grandest child :) will be called when a class is instantiated as an object.

Wow, now that I've done it that way, I can see why it's the better way.
By having to call the parent constructor from within the child object, It gives the child better control.

For example, my parent has a "database" object, and a built-in default way of talking to it; while the child has another way of talking to it - each established in the constructor, and each running a verification process to ensure it still works

So now I can have the child set the values for the conversation before the parent .... blah, blah, blah.

Bottom line - I talk to the DBMS once, instead of twice during initialization.

Cool.
Thanks.





Zat right?

Vocabulary question: When I do this, what is the OOP thing that I'm doing? You said that my use of an object as a property of the parent class was "aggregation. So - when I use use "extends" to create the child's reference to the parent - wassat? Marshalling? Inheritance?


.



Relevant Pages

  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)