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?