Solved

N-Tier Architecture in ASP.NET

Posted on 2013-01-10
3
471 Views
Last Modified: 2013-01-12
In this section, "Creating Business Access Layer (BAL):   (RecordBAL.cs)", I do understand the code. What I don't fully understand is is that all there is for Business layer? I don't understand how it benefits by just return data?

 "//and return the result to the caller of the method.
            return rdAL.RetrieveRecords(); " 

" Its responsibility is to validate the business rules of the component"  <<< If you have a sample, could you help me out what this mean?

http://www.mindstick.com/Articles/d36ceb0f-018c-4979-b2f5-a4a1e616cb5b/?N-Tier%20Architecture%20in%20ASP.NET
0
Comment
Question by:VBdotnet2005
3 Comments
 
LVL 15

Expert Comment

by:Minh Võ Công
ID: 38766037
0
 
LVL 25

Accepted Solution

by:
Luis Pérez earned 500 total points
ID: 38766518
Well, many times the business layer simply returns the data "as-is" from the data layer to the UI. But data in the database is not always stored exactly the same way that it must be shown in the UI, so therefore many other times you'll need to make some transformations in the data.

In the sample page you provided I miss one more layer, that I used a long time ago and I consider invaluable: the repository. In my projects, the UI layer doesn't know the database at all; in fact, in the UI I never use database objects like datatables, datasets, etc. For me, it's much clear to declare a repository layer where I create classes for all my entities. So when I need to retrieve, for example, a list of "persons" from my database, in the UI I don't get a datatable or dataset, but a list of Person objects. The Person class is declared in the Repository layer.

Now, let's back to the business layer. The business layer will be useful to you in 2 ways. First, when retrieving data from the database. In most cases, the data in the database is not stored exactly the same way that you need to show it on the UI. For example, my Person class does't need to be an exact copy field-to-field of what is stored in the database. So often you'll need to make some transformations to the data collected from the database. Following my example, the business layer would get a list of person records from the database and will fill a list of Person objects with those records, making some transformations in the data to fill right the Person objects.  When it's done, the list of Person objects will be sent to the UI.

The second way the business layer will be useful is when providing data to the database (new records, updates, deletions, etc). The BL will be the responsible to store your business logic. For example, you'll need to do some validations to the data provided when creating a new record. more over than the simple validations that you'll do in your UI (empty fields, etc). Imagine that you have this business logic: "It's not possible to create a person when his phone number already exists in the database". Well, in your UI you'll probably check that the phone number is not empty when creating the person, but you have no way to check directly from the UI if the phone number already exists. So in the UI you'll do some basic validations (mainly those format-related) and in the BL you'll do your business-specific validations. If the phone number exists in the database, the BL must return that condition to the UI in order to inform the user.

Wow... I hope this will be useful to you. It's not easy to me to express in English, as it's not my native language. I hope you understand what I wanted to say.
0
 

Author Comment

by:VBdotnet2005
ID: 38770496
I truly appreciate your help on taking time to write above. Wow, that helps alot.
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

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

861 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

23 Experts available now in Live!

Get 1:1 Help Now