Optimizing a Factory Pattern

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm looking for some advice from more experienced .netters. I would
like to use a Factory Pattern that accepts an ID number and returns an
object. As I may have a large pool of objects to choose from, I'm
trying to figure out the best strategy in retrieving the needed object.


The application is a stand-alone client. I'm considering a hashtable
that would populate at start-up. The key would be the ID and the value
would be the object. Each object would contain about 20
properties/members. Eventually, the number of objects could reach
about a hundred--possibly more.

Anyone have comments about this approach?

Thanks,
Eric
 
Eric -

Your idea of hash table looks ok but, consider this:

lets say your application reaches its peak, creating all the objects
and populating the hash table. Would that slow your application?

Did you consider creating not so frequently used objects when there is
a need through the factory instead of storing them?

HTH
 
I was just wanting to avoid a huge select case statement. I saw a
similar thread in the groups and someone recommended using Activator.
The class--not the hair product.

If I have ID 2000100, I want to create Object1. If I have ID 2000200,
I want to create Object2, etc. So, yes, I'd like to avoid creating
this huge hashtable full of objects if it would slow it down, but I'm
not sure of the best way to do this.

E
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top