D
davidw
As I asked in last post, I want to put some logic in a object and all my
webcontrol instance will access that object, the object is responsed to
retrieve data from database if the data has not been retrieved yet. Vadym
Stetsyak suggested me to use singleton, it seems a good solution for me, but
after I read more about singleton, I find another issue - if I use singleton
patter, I can not store context data in the class anymore. How I used the
class is that I assigned required data to the class's variables, and then I
called methods in the class to get result. If I use singleton pattern, how
should I tell the called method what are those context data? Should I pass
all them by parameters? It seems there gonna be a lot of parameters passing
around this way.
If it is a problem, should I just let each webcontrol create their own
instance of the class? Will the performance be a lot worse this way? (the
class includes quite a few method functions).
Thanks.
webcontrol instance will access that object, the object is responsed to
retrieve data from database if the data has not been retrieved yet. Vadym
Stetsyak suggested me to use singleton, it seems a good solution for me, but
after I read more about singleton, I find another issue - if I use singleton
patter, I can not store context data in the class anymore. How I used the
class is that I assigned required data to the class's variables, and then I
called methods in the class to get result. If I use singleton pattern, how
should I tell the called method what are those context data? Should I pass
all them by parameters? It seems there gonna be a lot of parameters passing
around this way.
If it is a problem, should I just let each webcontrol create their own
instance of the class? Will the performance be a lot worse this way? (the
class includes quite a few method functions).
Thanks.