Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why do we need to re-build the dictionary?
Message
 
 
General information
Forum:
C#
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01651719
Message ID:
01651742
Views:
33
>>Hi everybody,
>>
>>I see the following code being called:
>>
>>
>> static public Dictionary<string, object> GetPreferenceDictionary()
>>        {
>>            return BuildPreferencesDictionary();
>>        }
>>
>>
>>
>>and then in the same class
>>
>>
>> static private Dictionary<string, object> BuildPreferencesDictionary()
>>        {
>>            Dictionary<string, object> preferenceDictionary = new Dictionary<string, object>();
>>           //loading code here
>>
>>            return preferenceDictionary;
>>        }
>>
>>
>>
>>this method is called many times.
>>
>>Why cannot we just return the dictionary if it was already created?
>
>Maybe because the dictionary content might change between calls ? Where is it loaded from ?
>

In this particular case it was loaded when the menu was created (to allow dynamic labeling of the menu items). So, in this case there was not a chance of changing the content between calls (except if someone is changing the preferences from another workstation while that menu was generating).
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform