Service layer vs business layer - differences?
Asked Answered
C

1

12

I have been doing a lot of reading on service layers and business layers and how they compare. I have a read a number of the threads here on StackOverflow on the topic and i still find myself confused as to the differences between the two if there are any. To me it seems that its mainly a naming convention where one dev calls the middle layer a business layer and another may call it a service layer. From the code i have seen here on SO and around the web they seem to do mainly the same thing - that is query the repository, maybe do some filtering and/or validation and return the results to the presentation layer. So can anyone clarify the differences between the two? Or am i missing the mark in my assesment?

I am working with EF, MVC 3 and VBNET, FYI

Civilized answered 12/10, 2011 at 14:26 Comment(0)
J
15

In our projects we often have the following structure:

Service layer:

  • Publishes the Service Endpoint (this could be your MVC web page, or a WCF endpoint)
  • Does a security check
  • Maps data from contract data transfer objects to business objects
  • Calls functionality in the business layer

Business layer

  • Contains business logic
  • Accesses the data layer (this could be your entity framework data model)
Jaela answered 12/10, 2011 at 14:57 Comment(4)
I am a bit confused: Is a webpage part of the service layer? I am guessing you mean a URL maybe?Wrench
@ShirazBhaiji In which layer do you write validation rules?Devious
@Shiraz Bhaiji MVC web page should be on your presentation layer not service layer.Arman
Refer to this MSDN page to get more details about service layer and business layer msdn.microsoft.com/en-us/library/ee658090.aspxArman

© 2022 - 2024 — McMap. All rights reserved.