Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Referencing a parent's object
Message
From
27/08/2007 17:08:20
 
 
To
27/08/2007 15:10:11
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
01250681
Message ID:
01250759
Views:
26
>Just had a thought. What about using AddObject (or something like that) in the oxServer that creates the oHandler object, instead of passing it in? Or is that like having two mirrors facing one another?
>
You mean something like
oxHandler = CREATEOBJECT( "EMPS_Handler_Medinotes_Class" )
oxServer = CREATEOBJECT( "EMPS_Server_Class",m.Port,oxHandler )
oxServer.oxHandler.addproperty('oxServer',this)
I don't know if this is "proper" design, but you would wind up with each object having a reference to the other.




>>You could add a ParentObject property to emulate the Parent property of a container, so you can do
>>
>>
>>oxHandler = CREATEOBJECT( "EMPS_Handler_Medinotes_Class", this)
>>oxServer = CREATEOBJECT( "EMPS_Server_Class", this )
>>
>>
>>in both your classes, you have a ParentObject property, and in the Init you do:
>>
>>
>>function Init(toParentObject as Object) as Boolean
>>	this.ParentObject			= toParentObject
>>endfunc
>>
>>* Do not forget the Destroy!
>>procedure Destroy() as VOID
>>	this.ParentObject			= null
>>endproc
>>
>>
>>Now, both, oxHandler and oxServer can interact which each other thru their ParentObject Property, for example oxHandler can use this.ParentObject.oxServer.Port
>>
>>Of course, this is not a very good thing to do from an Object Oriented viewpoint, I wish my memory could remember what is the name of the rule we are violating here, but it should work <g>
>>
>>A better way (well, at least I think) would be that the Parent object is the guy handling all the events, like, lets say you still use ParentObject in both classes, but you never use oxServer or oxHandler from any methods in oxServer or oxHandler, instead, for example, frome the Acknowledgement procedure of oxHandler you just call this.ParentObject.Acknowledge([Parameters]) (which does have access and knowledge of it's childs) and the same with each method of this child objects that need some info from the other object
>>
>>>Agreed. Any ideas?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform