Solved

N-Tier Architecture in ASP.NET

Posted on 2013-01-10
3
498 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

628 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