Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Object coupling and reuse
Message
From
19/06/2000 16:29:47
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00381906
Message ID:
00381963
Views:
10
Evan,

If the GetModelName procedure is the only place in the Device Class that needs access to the Model class, just CREATEOBJECT the oModel inside that method and release it immediately after. Alternatively, Paul's suggestion is good. If, however, your Device class depends on oModel already existing when it instantiates, you are tightly-coupled.

>Is there any rule of thumb when balancing object coupling vs reusing existing objects? In the example below, the device object will return the model name, but it uses the model object to determine this.
>
>By tightly coupling the Device and Model object I am reusing the code to determine a model name, _BUT_ the Device object now relies on the Model object to exist.
>
>Here greatly simplified example:
>
>
>* Dept Class
>DEFINE CLASS Device AS Session
>	PROCEDURE GetModelName
>		PARAMETERS nDeviceId
>                * insert code to get fk_modelid
>                RETURN oModel.GetModelName(fk_modelid)
>	ENDPROC
>ENDDEFINE
>
>* Dept Model
>DEFINE CLASS Model AS Session
>	PROCEDURE GetModelName
>		PARAMETERS nModelId
>                SELECT model
>                SET ORDER TO id
>                SEEK nModelId
>                RETURN model.name
>	ENDPROC
>ENDDEFINE
>
David Stevenson, MCSD, 2-time VFP MVP / St. Petersburg, FL USA / david@topstrategies.com
Previous
Reply
Map
View

Click here to load this message in the networking platform