Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

N-Tier Architecture in ASP.NET

Posted on 2013-01-10
3
Medium Priority
?
500 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 2000 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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 …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

715 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