Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Set and Get appl obj property good practice
Message
 
 
À
31/07/2009 10:19:24
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01415630
Message ID:
01415656
Vues:
53
>> So I am going with array since I have never used collections before and even though it seems pretty straight forward from VFP help, I will refrain from starting now.
>
>Why not use a collection ? If it's a keyed collection, think of it as an array where the index is a string
>
>It's well worth investing a bit of time
>
>
>	#define METHATABLENAME_INDEXES	[IndexTable]
>	#define METHATABLENAME_PEOPLE	[PeopleTable]
>	
>	obj = createobject('Collection')
>	
>	obj.Add('\data\indextable.dbf', METHATABLENAME_INDEXES)
>	obj.Add('\data\peopletable.dbf', METHATABLENAME_PEOPLE)
>	
>	
>	&& get an item
>	
>	theIndex = obj.GetKey(METHATABLENAME_PEOPLE)
>	
>	if( empty(m.theIndex))
>		&& is not there
>	else
>	
>		? obj.Item(m.theIndex)
>	endif
>	
>	
>	&& or
>	
>	try
>		theData = obj[METHATABLENAME_PEOPLE]
>		?theData  
>	catch
>		&& 	&& is not there
>	
>	endtry
>	 
>
Hi Gregory,

First, thank you for sample code. It does look straight forward. I am not arguing that the collections approach is valid. Aside from my concern for making a mistake in something that I have never used before and breaking an existing application (which I am refactoring), I have the following point. Why is collections (in this particular case of storing a bunch of names) better than array? Array - with the help of an INLCUDE file - can be addressed with "key" names too.
"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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform