Forum Moderators: coopster

Message Too Old, No Replies

communication between classes ?

         

PHPycho

5:55 am on Jun 1, 2008 (gmt 0)

10+ Year Member



Hello forums!
One thing always comes on my mind while coding in OOP is that 'communication between classes'
I am searching for a effective communication mechanism between different classes in a OOP sytem.

Cases:
[PHP] class A{
//what should be the rule when it requires to communicate with B, C & D classes
}

class B{
//what should be the rule when it requires to communicate with D classes
}

class C{
// any other...
}

class D{
// what should be the rule if it requires to communicate with C class
}[/PHP]
Above is just the case of communication between different classes.

Can anybody point the good communication mechanism between different classes.

Thanks in advance for the valueable help.

xiongbin

6:19 am on Jun 1, 2008 (gmt 0)

10+ Year Member



can use extends

PHPycho

6:34 am on Jun 1, 2008 (gmt 0)

10+ Year Member



but its not effective to extend for unsimilar classes isnt it ?

PHPycho

10:07 am on Jun 1, 2008 (gmt 0)

10+ Year Member



What about registry pattern for holding and using objects in this case or else methods ?

mehh

11:46 am on Jun 1, 2008 (gmt 0)

10+ Year Member



I'm not sure if this is what you need but you could use this

class A{
}
class B{
var $A=null;
function B(){
$this->A=new A();
}
}

Also you may be able to do something with call_user_func_array [php.net] and func_get_args [uk2.php.net] so the arguments for the constructer are automaticly passed