|
singletone in .NET -- pavankumar --
can any one explain clearly about singletone in .net its advantages and disadvantages. -- Thanks & Regards Sayin(pavan) |
|
-- BradleyPeter --
Good question. I guess the stock answer is that if you make regular calls to a singleton SAO, it will stay alive and you will therefore save the overhead of the constructor and destructor calls that are associated with every call to a SingleCall SAO. However, as far as I can see, the disadvantages far outweigh the advantages: - It is not scaleable. If you have many calls to the same object something will eventually break. - If your object has state, some idiot will one day change it thus either affecting all other callers in an unexpected way or affecting itself when it thinks the state is one thing and it turns out to be another because the instance lifetime has been expired and the next call has reconstructed it with default state. OK, I know that it is a bad idea to have state in SAOs, but people do these things. They can also set the object's lifetime so that it never expires; but I don't think that that's a good idea either. Most of the time, these objects will just be clogging up the server's memory for no good reason. That's my opinion, anyway. Others may disagree, of course. IMHO having two types of SAO was not a good idea. If you want an SAO, use a SingleCall SAO. If you want something that stays alive, use a CAO. Peter |
|
-- Cerebrus --
Pavan... Can you clarify what exactly you are referring to by "Singleton" (which is incorrectly spelled as "singletone"). Is this the Remoting thingy or the Singleton design pattern you're talking about ? |
|
-- pavankumar --
singleton designpattern On 7/17/06, Cerebrus <zorg007> wrote: Pavan... Can you clarify what exactly you are referring to by "Singleton" (which is incorrectly spelled as "singletone"). Is this the Remoting thingy or the Singleton design pattern you're talking about ? > -- Thanks & Regards Sayin(pavan) |
|
-- Cerebrus --
Well, then : This is a good article on it < http://www.ondotnet.com/pub/a/dotnet/2002/11/11/singleton.html >Also < http://abstractvb.com/code.asp?A=1096 >Alternatively run a search for "singleton class vb.net" in Google. You'll get tons of results. |