0

Is it a good practice to implement the Facade pattern creating Singleton objects?

In the project I am developing, the facade object are going to be called from ASP.NET webforms server-side code, in order to encapsulate the domain logic.

EXAMPLE:

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
  }
}
dave
  • 2,291
  • 3
  • 19
  • 25
  • 1
    Please illustrate how you envision this, preferably with some code, as your question lacks a bit of body, so it's a little unclear what exactly you mean. Do you mean you have a facade class that you want to turn into a singleton? – CodeCaster Nov 15 '13 at 12:38
  • I have a facade class implementing singleton pattern and I am reconsidering if it is better to convert to a normal instantiable class. I'll add an example. – dave Nov 15 '13 at 13:45
  • 1
    `static` objects and multi-threaded environments generally don't go well together. – James Nov 15 '13 at 13:54

0 Answers0