Last post May 24, 2011 11:11 AM by RemyMartin
May 24, 2011 08:28 AM|RemyMartin|LINK
I have a data access component that i call from my aspx.cs file and it does everything and then sets datasources to the controls. Someone told me this is sloppy and unprofessional (in a nice way) and that i should create a business logic class and put everything
in my aspx.cs file into that as a class and then just bind the page to the business logic class. any suggestions?
May 24, 2011 09:03 AM|suresh_g_v2002|LINK
if u want to bind the data to a control like griview., you can use object data source control and bind the business object which has data to that..,
then u can bind the object data source control to gridview
check this for reference....
May 24, 2011 10:16 AM|abhisheks|LINK
It is true that when you put your data access component in code behind, it makes the code sloppy and hard to change. Having busines logic in objects helps to make changes easier. A nice place to start would be this tutorial on building business logic class
Having said that, you do not need to business logic class all the time. A good example may be data entry form, where you hardly need any sort of validation or business logic as such.
Depending on your need, you need to decide whether having business logic really helps your need. Doing too much for small problems always creates issues. Keeping it simple as much as possible makes it easier to maintain application in future.
Just my cent
May 24, 2011 10:19 AM|atconway|LINK
Yes layering your application using logical divisions is a basic architectural practice which helps adhere to OOP principals like encapsulation. Sounds like a lot, but this method of organizing your application code into meaningful layers will help the applications
readability, scalability, and maintainability.
In your case when the UI layer is directly accessing data access code, your are tightly coupling the logic, and probably squeezing in business rules directly in the webform once that data has been returned. A simple 3-layer (UI, BLL, DAL) logical layer architecture
will help organized code into their assigned responsible layer for the advantages I mentioned previously.
The best way to understand the concept and implementation of layering is to try it out and read up on a few examples. The links provided below should get you pointed in the proper direction:
Creating a UI-BLL-DAL:
3-tier Architecture with ASP.NET 2.0:
Building an N-Tier Application in .NET:
N-Layered Web Applications with ASP.NET 3.5 Part 1: General Introduction:
Hope this helps!
May 24, 2011 11:11 AM|RemyMartin|LINK
Wow, Thanks for all the help, i will check out the info!