开发者

session facade Vs Singleton object design patterns in ASP.Net

开发者 https://www.devze.com 2022-12-24 03:17 出处:网络
Can any one tell me which one is better between \"Session Facade Class\" and \"Singleton Object\" design patterns in ASP.Net? Also, please state the scenarios where specific design 开发者_JAVA百科patt

Can any one tell me which one is better between "Session Facade Class" and "Singleton Object" design patterns in ASP.Net? Also, please state the scenarios where specific design 开发者_JAVA百科pattern is advisable to use.

Thanks


The big differences will be in the lifetime and isolation of the objects. A facade over Session data will still have data that is only accessible by a single user's Session and will die once the Session is torn down. Singletons will last for the lifetime of the application and be accessible across all Sessions.

Singleton's can get you into threading problems if you are not very careful and thus, you should prefer Session data over a Singleton unless you have compelling reasons to do otherwise.

0

精彩评论

暂无评论...
验证码 换一张
取 消