session facade Vs Singleton object design patterns in ASP.Net
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.
精彩评论