Page 1 of 1

classes and methods

Posted: Thu Aug 24, 2006 9:28 am
by sparkle
Hi.
Let's say i have two classes, a and b. I would like to use a's methods AND variables inside b's functions. How do i do that?
1.Do i instantiate a inside of b::__construct?
2.Do i use a::function()? - i don't think a::variable would work though
3.Other ideas?

I've read articles about the observer pattern. I don't think i understood much, but i don't think i can use it here, right?

I would like to have a MVC foundation classes-style approach. I want the Model class's methods and variables to be accesible from the Controller, and Controller's methods and variables to be accesible from within the templates of the View.
What would be easier and most straightforward?

Thank you.

Posted: Thu Aug 24, 2006 9:33 am
by Oren
The Observer has nothing to do with it as far as I see it. What you really need is the Registry Pattern :wink:

Posted: Thu Aug 24, 2006 9:48 am
by sparkle
Right.Wow.:P
Great, it's the first time i hear of registry. And now if i think about it..it's damn simple. I just didn't see it.
Thanx. If you have any other important reading such as this one you gave me, please:D

Posted: Thu Aug 24, 2006 9:53 am
by Oren
http://www.patternsforphp.com
http://phpbook.quantum-star.com/doku.php?id=contentlist (<-- We are still writing this book... Actually, we have just started)