473,487 Members | 2,461 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Separating UI and data into layers

6 New Member
Hi.
I just cant seem to get my head around n tier application architechture where you have separate UI and data layers. I just dont get it, and cant see the point
I am finding myself spending more time trying to separate the 2 layers. I know you are all thinking "idiot!", so I shall explain.

Ive been learning C# and .NET2.0 for about 1 year, and I feel that my problem stems from the fact that I have been coding in Classic ASP for the last 10 years.

The last web project I worked on implemented a data layer. This was simply a c# class where we dumped all the database actions. (I'm not even sure if this is a true data layer)
Coming from Classic ASP, I previously wrote ALL UI and data code in the same file, using functions and subS for handling all my database calls, but now all I hear is "you must separate the data and UI layers as it makes life easier."
Well firstly, now I have 2 files that I need to maintain per webpage whereas before it was just one. so, how is this better? Someone told me that it allows me to change the data layer without affecting the UI, but if the UI displays what the datalayer outputs, then surely there must be some UI database code for handling the returned data?

For example, if I have a GridView, then my templateFields and Bound fields also be altered in the UI if I change the SQl statement in the data layer.

Is the rule that you must NEVER have ANY database statements in your UI? Or just to reduce it? If my datalayer returns a Datarow to my UI, am I allowed to refernce the table-fields so as to populate controls, or should the values be returned as strings or some other data type?

There are a milliion articles out there, but I havent found any that really explain to beginners why this concept is so important, showing 'bad examples' and exaplaining WHY they are bad.
Please could some kind coder explain this?
Oct 21 '07 #1
3 3149
RedSon
5,000 Recognized Expert Expert
Maybe this will help:

http://en.wikipedia.org/wiki/N-tier
Nov 2 '07 #2
gjok
6 New Member
Thanks RedSon,
Not sure if that helps though. The thing is I do Windows programming and web development. The article says that n-tier archticture means something different depending on whether you are programming for Desktop or Web.
i.e Web
  • A front end Web server serving static content
  • A middle dynamic content processing and generation level Application server,
  • A back end Database,

The way I am having to learn web programming with .NET is: more like Desktop, with a DLL for the Presentationlayer, and a DLL for Data layer - but still using the methods outlined in the list above.

I have since found the answer to one of my questions though:
>>"If my datalayer returns a Datarow to my UI, am I
>> allowed to refernce the table-fields so as to populate controls"
Apparently that is acceptable.

cheers.
Nov 20 '07 #3
gjok
6 New Member
OK, this was nice to read:
http://worsethanfailure.com/Articles...ess-Layer.aspx
Nov 28 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
4614
by: Anon Email | last post by:
Hi people, I'm learning about header files in C++. The following is code from Bartosz Milewski: // Code const int maxStack = 16; class IStack
2
2195
by: headware | last post by:
I'm relatively new to ASP.NET and ADO.NET, but I have a basic design question regarding the use of web services and APS.NET applications. Right now we have an application that uses web services to...
2
12532
by: Matt | last post by:
When we submit the form data to another page, we usually do the following: <form action="display.aspx" method="post"> will submit the form data and open display.asp in the current browser ...
13
2499
by: Michelle | last post by:
Hi all... I could use a little TLC here for understanding and not for solving a specific problem... sorry if I've got the wrong group, but I'm using VB so I figured this was the most appropriate...
8
1795
by: Jeff S | last post by:
Please note that this question is NOT about any particular pattern - but about the general objective of separating out presentation logic from everything else. I'm trying to "get a grip" on some...
10
1234
by: William Buchanan | last post by:
Hi folks Can anyone point me in the direction of any information on how to make a data layer which will work with the new ASP.NET 2.0 data components (GridView, etc)? The reason I ask is...
13
3081
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those...
5
1363
by: AAJ | last post by:
Hi all FIRST THE BORING BITS....... I normally use a Database layer, a Business layer and a GUI layer. The GUI uses an Object data source to bind to the Business layer which in turn binds...
0
2385
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
0
7108
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6967
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4875
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3078
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.