tags:

views:

487

answers:

5

Using VB.NET 2008

I want to know what is 3 Tier Architecture for windows application?

Can any one give a example of How to make a code for Inserting, Deleting, Updating in a database using 3 tier architecture.

Note am not asking a real code. Just give me a example.

+1  A: 

From Multitier architecture

Three-tier'[2] is a client-server architecture in which the user interface, functional process logic ("business rules"), computer data storage and data access are developed and maintained as independent modules, most often on separate platforms.

rahul
+1  A: 

These days, a normal 3 tier application consists of a user interface written in Javascript, CSS and HTML which runs in the browser, a business rules layer which runs in a web server, and could indeed be built in VB.NET, and a storage layer which runs on a database server written in SQL and stored procedures.

Now it would be possible to do a user interface layer in VB.NET as a Windows application which then calls the business rules layer on the web server using a web services interface. This would give you more flexibility than the browser, and would not require learning as many APIs, however it is not common. It can really only be done in an enterprise situation.

This article has a simple VB.NET application that is a Windows GUI app, which call Google's web services API to do searches and to check spelling. That is a good example of a user interface layer. Then check this article for and exmple of a web service developed in VB.NET. This corresponds to the business rules layer, and in a real 3-tier application, it would be based around a database such as SQL server. If you were to use Access then it would not be a real 3-tier application. The database needs to be run on its own server and accessed across the network in order to be considered a tier.

The advantage of a 3-tier application is that you can scale each layer separately, and because each layer is simpler, scaling is also simpler. The DBAs can scale up to a database cluster, the business rules layer can scale up with a load-balancer and multiple servers, and the user-interface just gets replicated across as many clients as you need.

Michael Dillon
+1  A: 

I don't know if is it the rigth way to use it, but I often use 3-tier int the following way:

  • One big Solution, with the name of the proyect
  • One dll proyect wich has the conection with the DB, using LINQ or whathever. Validating only the required fields of the DB
  • Another DLL proyect, wich has a reference to the proyect that conects to DB, and validate all data using the bussiness rules. Sometimes you may want a repositorium class wich has methods that can be used from the GUI layer
  • Finally, the GUI layer that can be HTML or WINForms, wich references to the bussines layer and calls all the appropiates methods, passing the data transparently and waiting for validation on the bussines rules.

You can comunicate each layer using bool methods that returns true if everything is good, and personalized exceptions for each of the possible errors, and catch them on the upper layer.

josecortesp
A: 

I find the best way to understand it is to look at an example. If you go here: http://www.codeproject.com/KB/vb/N-Tier_Application_VB.aspx

You can download an example and read the walk through for creating a very basic 3 Tier App in VB.Net. It's a little old in that it's a Visual Studio 2003 project but it should be easy enough to follow the upgrade wizard and get it up and running to check it out.

brendan
A: 

I'll give you the gist of it. Real crash course.

You have three tiers:

  1. DAL - Data Access Layer
  2. BRL - Business Rule Layer
  3. Presentation - The Forms, and such.

In the DAL, you configure how your application connects to databases, how it recieves datasets, etc. etc. Everything that has to do with data access.

In the BRL, you lay down how your program is going to handle the data it recieves from the DAL. Methods, and other things go in here.

And in the Presentation area, you simply make things purty and instantiate things from the BRL. The presentation area never has to touch the DAL, and that's the beauty of the 3tier layout. You can work on different areas and not step on other peoples toes.

Sergio Tapia