title: Factory pattern with 4 layer architecture
body: <p>In my project i have 4 layers presentation,BL,DL, and dataObjects. i want to implement abstract factory pattern to get the object i want(doctor/Engineer). Is  the code below implementing factory pattern? </p>
  
  <pre><code> public interface IProfessional //The Abstract Factory interface. 
  {
      IProfession CreateObj();
  }
  
  // The Concrete Factory  class1.
  public class DocFactory : IProfessional
  {
      public IProfession CreateObj()
      {
          return new Doctor();
      }
  }
  
  // The Concrete Factory  class2.
  public class EngFactory : IProfessional
  {
      public IProfession CreateObj()
      {
          // IMPLEMENT YOUR LOGIC
          return new Engineer();
      }
  }
  // The Abstract Item class
  public interface IProfession
  {       
  }
  
  // The Item class.
  
  public class Doctor : IProfession
  {
    public int MedicalSpecialty
   {
    get; set; 
   }
    public int AreaofExpertise
   { 
    get; set; 
    }
  
  }
  // The Item class.
  public class Engineer : IProfession
  {
    public string Title{
       get;set;
  }
    public int AreaofExpertise 
  { 
   get; set; 
  }
  
  
  }
  
  
  // The Client class.
  public class AssignProfession
  {
      private IProfession _data;
  
      public AssignProfession(DataType dataType)
      {
          IProfessional factory;
          switch (dataType)
          {
              case DataType.Doc:
                  factory = new EngFactory();
                  _data = factory.CreateObj();//from here i will get engineer
  
                  break;
              case DataType.Eng:
                  factory = new DocFactory();
                  _data = factory.CreateObj();//from here i will get doctor
  
                  break;
          }
      }
  
      public IProfession GiveProfessional()
      {
          return _data;
      }
  }
  
  //The DataType enumeration.
  public enum DataType
  {
      Doc,
      Eng
  }
  </code></pre>