Solved

c# How do I manage database connections the three tier architecture?

Posted on 2011-02-13
4
784 Views
Last Modified: 2012-08-14
Hi guys,

I am new to object oriented programming. I have programmed in the top down world for a few years now, but find that OOP is a more efficient way to program. my question is twofold really.

1. With the DAL, is the best practice having something like a dbhelper class and also having a separate DAL for each class that utilizes the dbhelper class? Or is it best practice to have a DAL for each class that processes your data for you?

2. With question number one in mind, what happens if I need to populate 8 drop downs in a class and I need to have 1 connection for all 8 drop downs? it ust seems like the db helper class would work against that. I want to manage my connections as much as possible.

thanks in advance!
0
Comment
Question by:bschave2
4 Comments
 
LVL 8

Accepted Solution

by:
jimsweb earned 0 total points
ID: 34883237
What is a 3-tier architecture?

Three-tier (layer) is a client-server architecture in which the user interface, business process (business rules) and data storage and data access are developed and maintained as independent modules or most often on separate platforms. Basically, there are 3 layers, tier 1 (presentation tier, GUI tier), tier 2 (business objects, business logic tier) and tier 3 (data access tier). These tiers can be developed and tested separately.

What is the need for dividing the code in 3-tiers? Separation of the user interface from business logic and database access has many advantages. Some of the advantages are as follows:

    * Reusability of the business logic component results in quick development. Let's say we have a module that handles adding, updating, deleting and finding customers in the system. As this component is developed and tested, we can use it in any other project that might involve maintaining customers.
    * Transformation of the system is easy. Since the business logic is separate from the data access layer, changing the data access layer won¿t affect the business logic module much. Let's say if we are moving from SQL Server data storage to Oracle there shouldn¿t be any changes required in the business layer component and in the GUI component.
    * Change management of the system is easy. Let's say if there is a minor change in the business logic, we don¿t have to install the entire system in individual user¿s PCs. E.g. if GST (TAX) is changed from 10% to 15% we only need to update the business logic component without affecting the users and without any downtime.
    * Having separate functionality servers allows for parallel development of individual tiers by application specialists.
    * Provides more flexible resource allocation. Can reduce the network traffic by having the functionality servers strip data to the precise structure needed before sending it to the clients.

More on this:
http://www.codeproject.com/KB/architecture/three_tier_architecture.aspx
http://www.codeproject.com/KB/cs/Three_Layer_Architecture.aspx

Hoe the above articles throw some light into your requirement.
0
 
LVL 5

Expert Comment

by:jaiminpsoni
ID: 34887728
It certainly helps to have helper class which will have some static methods to remove the duplications.

I am not sure why you neew to have "1 connection for all 8 drop downs".

Have you thought about implement connection pooling? Assume that your DB Helper class has access to connection pool with 4 connections. If more connections are available, it will use it...may be this will improve the performance by some extent.

Just my 2 cents....
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question