title: how to use singleton and/or factory patterns in business logic layer
body: <p>I understand the purpose of singleton and factory patterns, however I have doubts implementing it. My problem is that whenever I need to call a method from BLL, then I have create an instance of BLL class (please see the end of the code below). So, I am not sure if this is a proper singleton pattern implementation.  I will try to briefly explain the layers that I am using for years in my application:</p>
  
  <p>DataAccessLayer</p>
  
  <pre><code>public sealed class DataAccess
  {
      private static readonly string path = "SqlServerDAL";
      public static IDAL.IPost CreatePostInstance()
      {
          string className = "SqlServerDal.Post"
          return(IDAL.IPost)Assembly.Load(path).CreateInstance(className))
      }
  }
  </code></pre>
  
  <p>InterfaceDataAccessLayer</p>
  
  <pre><code>public interface IPost
  {
      IList&lt;PostInfo&gt; GetPostsOfUser(Guid userId);
  }
  </code></pre>
  
  <p>SQLServerDataAccessLayer</p>
  
  <pre><code>public class Post: IPost
  {
      public virtual IList&lt;PostInfo&gt; GetPostsOfUser(Guid userId)
      {
          //Sql code to retrieve the data and create the IList&lt;PostInfo&gt;
      }
  }
  </code></pre>
  
  <p>Model Class</p>
  
  <pre><code>public class PostInfo
  {  }
  </code></pre>
  
  <p>Business Logic Layer</p>
  
  <pre><code>public class PostBLL
  {
       private static readonly IPost dal = DALFactory.DataAcess.CreatePostInstance();
       public IList&lt;PostInfo&gt; GetPostsOfUser(Guid userId)
       { 
           return dal.GetPostsOfUser(userId);
       }
  }
  </code></pre>
  
  <p>And, I call the BLL class like this from the aspx pages:</p>
  
  <pre><code>PostBLL managePost = new PostBLL();
  managePost.GetPostsOfUser(userId);
  </code></pre>
  
  <p>Is this structure and pattern use appropriate? I have been using this for years but not sure if it is effective and correct.</p>