Solved

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

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

707 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

17 Experts available now in Live!

Get 1:1 Help Now