Last post Mar 27, 2014 04:18 AM by Kevin Shen - MSFT
Mar 26, 2014 01:22 PM|stephenmbell|LINK
When talking about separation of concerns, business logic vs presentation layer, I feel like I may be confusing myself.
I am writing a method in my application that will retrieve data from the database, stuff this data into a collection of my custom objects, and serialize these objects to xml files - 1 file per object in the collection. I have this working - my question
is more of a "where" than a "what".
I have a button on my webform - click this button, call a method in my BLL, that does nothing other than calls a method in my DAL and forwards my parameters along. In my DAL, the method connects to my database, calls a stored procedure, puts the results
into a collection of my custom objects, returns them to the BLL, which returns this collection of objects to my UI.
From here, in my UI layer, I look through each object in the collection and call a method to export these objects to xml files. I use my web config file to store the path where these files should go, how they should be named, etc. My question - should
this be done in my UI layer or BLL layer? Or somewhere else?
Thanks in advance.
Mar 26, 2014 03:25 PM|Mikesdotnetting|LINK
Anything in the UI layer should only concern the presentation of data in the UI. If your code does something other than that, it's in the wrong place. The descirption of your workflow doesn't include any presentation of the data you are processing so it
seems like the processing logic should not be in the UI. It should be in the BLL - or an adjacent service layer.
Mar 27, 2014 04:18 AM|Kevin Shen - MSFT|LINK
UI Layer ,which is the top level of the application, focus on how to present the data and handle the interaction with the user .
In simple terms it is a layer which users can access directly such as a web page, or Window Form ,or an operating systems GUI. It should not contain any business logic or data access code.
Business Logic Layer, which is in the middle of the three –tier Architecture. It accepts the input from the UI Layer, processes the information through the set of rules, and passes the date to the data access layer , and after the data access layer processes
the date , It will transfer the date to the UI Layer for user.
According to your description about your project , It had no relationship with UI Layer.
For the UI Layer just focus on how to display information. While you have a lot of work to with business logic about how to look through each object in the collection and how to export to xml files. They all belong to Business Logic Layer.
Hope my answer will be helpful for you.