Sunday, May 11, 2008

Multi tier programming –Part1

see these Related topics:

  1. Multi tier basics
  2. A best practice for multi tier architecture
  3. A sample code based on best practice
  4. Examine utilities to speed up Multi tier programming- NLog
First of all having a good understanding of multi tier programming is really important. Then we need to look into how we can implement it. What is a good practice especially for web applications? Unfortunately Multi tier programming needs massive time in terms of implementation so how we can utilize speeding at the same time write our code in this architecture?

Let’s start with what is multi tier programming?
Multi tier programming suggests that instead of writing code in just UI we need to separate our applications code to various layers. What does layer mean? Each layer provide some classes that having a unique purpose like one layer is just to check your business rule or do complex calculation to satisfy your business. Another layer can have responsibility for saving and retrieving data. Be careful we do not suggesting that these layers should be in different computers all we suggest is that we need to separate our application code to different layers logically. Let’s understand this concept in one example:

We need to save and show information of some customers. Customers’ data exists in an Access database. We are asked to create a web application to show these data. So we create two pages one page to save new customer information another for showing all customer data. To implement each page usually we write some code in code behind of that page to save or retrieve data then we bind to database. This is wrong! I know that some of us have been doing this for years and everything was fine but I will convince you that is absolutely wrong. We get back to this issue that why this is wrong. Multi tier programming suggests that we can have one class to save and retrieve from data base (which can be our data access) another class to work with previous class and apply possible business rules and finally in UI to save and load information, object of business class should be created. It seems the code that could be very simple is more complicated. Yeah this is true it is a little bit more complicated however, it is definitely worth it. Why?

Reasons of using multi tier programming:

It helps you to separate each layer purpose so finding a code will be much easier. You can replace each layer let’s say in last example what if you need to change your database to SQL server then you need just replace data access layer.
In next part of multi tier programming you will see a good practice that can be used with full sample code.

4 comments:

Mitra said...

Hello,
I'm glad to meet you here.
I think ,you are the best teacher that I have ever seen.
I hope you be successful every time.
I like to follow your online lessons.

Your student , Mitra Iranpour

Emad Yazdanpanah said...

Hi Mitra,
I so much miss you guys. I love you all. believe me I plan to put as much as you can since I can not leave without teaching. Just be ready specially for web That would be the biggest shut

vivek said...

Hi Emad,
This is Vivek
Im a .net programmer also a sql report engineer for my company. I want to say you one thing i have never gone with disappoiontment everytime when i refesh your tutorial i have been using it for few months. Thanks
Vivek.

Manjula B said...

Hi Emad,

Excellent post. I have never seen such a simple and effective writing in .net tech topics.This is what is needed for everyone. Not the one which would use your time to just understand the big technical words.Thanks,

Manjula.