Sunday, May 4, 2008

N-Tier Architecture

What N-tier archeture means?
This refers to the architecture of an application that has 3 to N logical layer each layer is responsible for specific function and interacts with only the layer directly below.
Why N-Tier architecture?
You can easily scale out your application by deploying each layer on separate server. As each layer is totally separate and encpsulated from other layer so you can easily update/modify any layer without affection other layer or need to recompile them all. Here is the power of the n-tier as any additional features or change to a layer can be done without redeploying the whole application. Before we go further let’s have a look on this image

An n-Tier application usually has three tiers, and they are called the presentation tier, the business tier and the data tier. Let's have a look at what each tier is responsible for.

Data Tier: The data layer can usually be split into two separate layers. The first will consist of the set of stored procedures implemented directly within the database. These stored procedures will run on the server and provide basic data only. Not only are they pre-compiled and pre-optimized, but they can also be tested separately, Second layer will consist of set of classes which handle the stored procedure we call it CRUD operation (Create, Read, Update, Delete).
If your database changes for any reason, you can easily modify your data layer to handle them without affecting any other layers. This considerably simplifies maintenance.

Business Layer: this layer will encapsulate your busniss rule and logical validation; here we find classes which implement your business functionality. They neither access data (except through the data layer) nor do they bother with the display or presentation of this data to the user. All we are interested in at this point are the complexities of the business itself. By isolating this functionality, we are able to concentrate on the guts of our system without the worry of design, workflow, or database access and related concurrency problems. If the business changes, only the business layer is affected, again considerably simplifying future maintenance and/or enhancements.

Workflow Layer: This is one of the optional layers and deals with data flow to and from your system. It may or may not interact directly with the user interface, but always deals with external data sources. For instance, if you send or receive messages from a messaging queue, use a web service for extra information, send or receive information to another system, the code to handle this would be in this layer. You may wish to wrap your whole application in XML so that the choice of presentation layer can be expanded. This would also be handled in the Workflow Layer.
Presentation Layer: This layer handles everything to do with the presentation of your system. This does not just include your windows or web forms (or your user interface), but also all the classes which will help you present your data.


I hope this quick preview will help you

No comments:

RSS Feeds