Solved

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

Posted on 2011-02-13
4
779 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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 …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

930 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now