Reputation: 867
I am currently working on a asp.net site which has a 2 tiered architecture. UI and DAL. This is a site which has alot of logic in triggers and obvioulsy most of the logic in the UI. I would like to add a 3rd layer which is a business layer ,so as to be able to allow for re use of code, be able to do unit tests etc.
Has anyone ever done this , moved from a 2 tiered to 3 tiered archecture and if you have then how did you approach it. Did you just start writing any new code with 3 tiered and leave the rest etc? i would also consider MVC etc but i think that this maybe too much work.
thanks niall
Upvotes: 0
Views: 209
Reputation: 1039100
There are two approaches:
For example when Microsoft designed the ASP.NET MVC framework they chose the second approach: they introduced abstractions like HttpContextBase, HttpRequestBase, ....
So if you don't have time to rewrite everything from scratch you could start by thinking how your service layer might look and start designing POCOs and interfaces which would define the operations with those POCOs. Then the UI layer would only know about the service layer. In the implementation of this service layer you could use repositories which represent the CRUD operations with your entities and in the implementation of those repositories you would have the data access code you are currently having.
Upvotes: 3