Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Set and Get appl obj property good practice
Message
From
31/07/2009 09:22:30
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01415630
Message ID:
01415637
Views:
64
>Hi,
>
>I need to add about 10 (max) propertied to the application object. These properties will hold names of various meta tables of the application. Then, in many places of the application, this values will be retrieved and used. I know of two approaches
>
>1. Create a separate property for each one of the meta names (e.g. "MyMetaTbl1", "MyMetaTbl2", etc.). Then I would have to have as many Get methods in the application object to retrieve these values (e.g. method GetMyMetaTbl1, method GetMyMetaTbl2, etc.
>
>2. Create an array property for the application object with number of elements corresponding to the number of meta table names I need to store. Then I can have just one method of getting the values (e.g. GetMetaTableName(nEle))
>
>I am leaning toward the approach 2 but want to be sure that I am not going to miss something
>
>What is a better practices?

I suggest using an array (or a collection) for properties related among themselves. For example, an array with references to all open forms. If you have unrelated properties, it is convenient to be able to access by name.

As to get and set methods... I understand that in Java, for example, this is the recommended practice, to encapsulate (hide from other parts of the program) details about the internal workings of the class. However, in Visual FoxPro 6 and later there is another way to do this - access and assign methods. In other words, you may decide to store a value in an object property, which has a certain name, type, and data structure. But if you later decide to change the internal workings of the object, you can intercept calls to the object, from outside, with access and assign methods - and store the information in a completely different way - without having to change programs that call it.

Now, I don't know whether this is a "recommended practice", but it does give you an alternative.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform