Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Storing Information in a Scripting Dictionary

Posted on 2013-06-20
4
371 Views
Last Modified: 2013-06-22
Hi All

I am using a scripting dictionary to store information e.g. captions for userforms.  This allows me to populate the userforms with text from outside the VBA project which I find convenient.

My question relates to best practice for scripting dictionary use..

Say, for arguments sake, I have 100 user forms and 1000s of captions.  And lets assume the userforms are opened and closed frequently.  And lets also assume that the information for each userform comes from a different source...

Should I set the scripting dictionary to Nothing after each instance of its use?

Or, is it ok to let the dictionary grow? (it can't grow indefinitely as its size can't exceed that of the combined information sources).

If killing off the scripting dictionary is not required, then should I load everything at once (e.g. when the document loads) or add to the dictionary bit by bit (e.g. on an as needed basis as each form is used)?

Would it be better to use 1 large dictionary or several small ones (assuming I don't need to set it to nothing after each use).

I guess, in a nutshell, I'd like to know the pros and cons of keeping the dictionary in memory (real impact, ways to avoid any detrimental impact?) versus continually loading and setting to nothing... what's more efficient??

I have more questions, but they may become irrelevant depending on the answers to the above.

Cheers,
0
Comment
Question by:DrTribos
  • 2
  • 2
4 Comments
 
LVL 59

Assisted Solution

by:Chris Bottomley
Chris Bottomley earned 500 total points
ID: 39264930
Leaving out the fact that the pc is always limited by disc/memory it takes processing to create objects therefore since you talk in terms of "after each instance of its use" this implies that the data in the dictionary has a limited 'life' and that you grow it for convenience.  This being so then try the removeall method to reset the dictionary back to 'new' and leave the dictionary object otherwise as is.

Chris
0
 
LVL 15

Author Comment

by:DrTribos
ID: 39267379
Hi Chris

Long time no see! I think you make a good point and I always like a third option.  

Some of the data would be used more than other data, and I think keeping the dictionary alive will make some of the code simpler... but instead of emptying the object what do you think of the idea of removing certain keys(?) and their associated values for data that is less used?

Or would it be better to have several empty dictionaries; all ready to be used with their specific type of data?  

What would bog the system down more - 1 big and full dictionary or a bunch of empty dictionaries?

From a purists view of programming:
Is it bad to keep an object like a dictionary alive?
Should I take active steps to minimize the size of the dictionary?
At what point would size become an issue?

Cheers, S
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 39267598
I stress I am no expert in these matters but multiple dictionaries have to be harder on the system albeit overall trivial.  I do not believe size of a dictionary is particularly significant either but although i've used some huge ones ... yours could be bigger <g>.  At the end of the day I am sure that with sensible use of one or more dictionaries the limitations are going to be resource based and therefore unless using a dictionary for each individual key it is my experience that you can do pretty much whatever you want.

That said, if some data will be used more others then does it make sense to have a few dictionaries to cover the scope of data and clear them individually before re-use?

Note underlying my preference to reset or use multiple dictionaries is that sometimes outside of my knowledge I  am always afraid a duplicate key will exist and be missed or overwrite a required key and hence resetting periodically simply appeals to my fears.

Chris
0
 
LVL 15

Author Closing Comment

by:DrTribos
ID: 39267964
Thanks for your thoughts Chris
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question