Home All Groups Group Topic Archive Search About

Optimizing a Factory Pattern

Author
1 Feb 2006 4:16 PM
Smith.Eric.sNO_SPAM@gmail.com
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

Author
1 Feb 2006 5:37 PM
sricharantk
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
Author
3 Feb 2006 2:11 PM
Smith.Eric.sNO_SPAM@gmail.com
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