实现Facade模式创建Singleton对象是一个好习惯吗?
在我正在开发的项目中,将从ASP.NET webforms服务器端代码调用facade对象,以封装域逻辑。
示例:
public sealed class UserFacade { private static UserFacade instance = null; private UserFacade() { } public static UserFacade Instance { get { if (instance == null) { instance = new UserFacade(); } return instance; } } public void DoSomethingRelatedWithUsers() { //Logic here } }