locked
3 Layer Architechture RRS feed

  • Question

  • namespace Model
    {
    	public class Person
    	{
    		public string Name { get; set;}
    	}
    }
    
    
    namespace DataLayer
    {
    	public interface IPersonRepository
    	{
    		int Create(Person person);
    	}
    
    	public class PersonRepository : IPersonRepository
    
    	{
    		public int Create(Person person) 
    		{
    			//SQL Insert Here
    		}
    	}
    }
    
    namespace BusinessLayer
    {
    	public class BusinessLayerPerson:IPersonRepository
    	{
    	
    			PersonRepository personRepository;
    			public BusinessLayerPerson()
    			{
    				personRepository=new PersonRepository();
    			}
    			
    			public int Create(Person person)
    			{
    				return personRepository.Create(person);
    			}
    
    	}
    }
    
    namespace UI
    { 
    	public class  Person
    	{
    
    		public void SavePerson(Person person)
    		{
    		BusinessLayerPerson person=new BusinessLayerPerson();
    		person.Create(person);
    		}
    	}
    }

    What is the reason behind creating another layer like this if i can directly talks to the datalayer? If i do have a lot of sql code i will need to create a business layer class for each, so am starting to think what will be the benefits of having a layer in between the data layer and the UI.

    Regards

    Monday, August 28, 2017 2:06 PM

All replies

  • basic principles of the architecture and design apply, scalability, relaibility, availbility , ease of maintenace, avoid single poinnt of failure and so on, while the requirements of having multi layer or tier is dependent and application requirment specific but best practices will lead to the having multi layer or tiered approach

    Mark as answer if it helps


    Thanks and Regards Azhar Amir

    Wednesday, December 20, 2017 8:32 AM