Explain 3 layer architecture ( .NET Interview questions)?
Before proceeding please see this video created by www.questpond.com which explains 2 layer architecture
Layering is a software design methodology where we divide software in to logical pieces for better management. Big software applications have large number of modules and lot of lines of code. A good software is that software where we make change at one place, should not lead to making changes all over places.
In three layer architecture we divide software in 3 logical layers UI (User interface), BL (Business logic) and Data access layer.
Every layer in 3 layer architecture are meant to handle nature of specific responsibility, below table mentions those responsibility in more details.
This layer handles how the UI will look like. So this layer define attributes like colors , positioning , styles etc.
This layer handles business validations and they represent real world business objects.
Data access layer
This layer handles interaction with database. This layer fires SQL and does CRUD operation i.e. Create, read, update and delete data.
Advantages of 3 layers:-
- Helps to manage your application in a better manner as changes in one layer does not have large effect in the other layers. For example if you make changes in the business logic you do not have to change UI and data access layer.
- The reusability of the project increases. For example we can use the same business layer for mobile UI or Web UI.
- In 3 layers because we have divided project in to logical pieces we can do parallel development. In other words designer can work on the UI part to define look and feel and the same time developers can work on business logic and SQL. This will help to complete the project in less time.
- Configuration of 3 layers is easy as compared to single layer or two layer. For example by just changing configuration my data access layer can either use SQL Server database or oracle database. When these configuration changes happen my other layers do not need to worry about it.
Disadvantages of 3 layers:-
- The project becomes complex as we have divided the project in to layers. So we need skilled developers who understand 3 layer architecture and how to code in each layer.