Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Referencing a parent's object
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
01250681
Message ID:
01250772
Views:
16
>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?

AFAIK it's called 'tight coupling' or something along the lines. I was thinking in the direction of letting the parent handle the job too.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform