Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Separate public object or property of public obj?
Message
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01319132
Message ID:
01319189
Views:
22
>>Hi,
>>
>>I am looking for suggestions to the following decision I have to make:
>>
>>I have a public object (oApp) already working in the application. Now I need to add an object (also public) that will have a bunch of methods that I want to have available in every place of the application. I can add this new object to the application as a public object or I can add it as a property of the already existing one (oApp). For example:
>>
>>
>>*-- Choice 1:
>>public oCommon
>>oCommon = newobject("common_functions","my_commonlib.vcx")
>>
>>*-- Choice 2:
>>*-- public object oApp already exist.
>>oApp.oCommon = newobject("common_functions","my_commonlib.vcx")
>>
>>
>>What is a better approach in terms of memory management?
>>
>>Thank you.
>
>I'm not sure which is better in terms of memory management. In terms of OOP, neither is appropriate IMO. You're trying to emulate the old dBASE procedure library. The correct way to do this IMO is to build the class library into your application and then instantiate objects and call methods as needed.
>
>If you really want SET PROCEDURE behavior, that's still available to you, no need to use a class or object at all.

I think you either misunderstood my intent or I didnt explain it well. I don't want the SET PROCEDURE behavior with a set of functions. The main reason is the VFP functions can return only one value. I know you can return an array but it is a kludge. I prefer to have a set of methods of a globally available object. The advantage with methods is that multiple values can be returned to the calling procedure, using object properties.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform