Question

I have a web app with a presentation layer and a business layer as individual projects. One being a web application and the other being a class library. I have added a web reference to the web application to use a web-service. I am having no trouble using the service API but Im finding myself adding a lot of business layer type logic in my presentation layer to utilize this API. I would love it if I could just change some of my business layer code to work with the web service, but the configuration of such sounds like a big circular no no. Anyway I would love to have my objects be able to keep doing what they're doing but have it also work with a web-service, but i find myself having to create a helper/manager class in my presentation layer to work with the web-service. This causes me to require code changes everywhere I was performing the actions on the objects that I wanted to add to with the service. What is the correct way of attacking this issue?

Im not even sure there is a legitimate question anywhere in all that rambling but if anyone could offer any helpful words i would be greatly appreciative.

Thanks!!

Was it helpful?

Solution

The way that I have approached this is to create something to this effect:

  • Data Access Layer
  • Business Logic Layer
  • Service Layer (Devoid of any business logic, just an interface)


  • Service Access Layer (Devoid of any business logic or presentation logic)

  • Presentation Layer (MVC, Presentation Logic, etc...)

Your Service layer being devoid of business logic now can be changed without affecting your business logic. Your Service Access layer on the client side shelters you from changes in the service interface as well.

OTHER TIPS

If your service layer exposes only service-like methods (like perhaps simple CRUD methods as SaveInvoice(InvoiceDTO)) then in most cases you should be ok. However, we could use some code from your side.

There are really many ways of building service layers, statefull, not-statefull etc etc, so try explaining what repetition you get in your presentation

Perhaps you should have your service encapsulate the business logic as well? That way, your presentation layer would only access the service - the service would access the business logic layer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top