3

I need the exact purpose of Service layer in MVC. Can we implement without service layer.. What are the major responsibilities of these layers.. Can we implement without anyone of these layers..

Can you please someone help me to know this..

Girija V
  • 73
  • 9
  • 1
    Possible duplicate of [Do I really need a service layer?](https://stackoverflow.com/questions/9633498/do-i-really-need-a-service-layer) – Cà phê đen Jan 09 '18 at 03:49

2 Answers2

1

The service layer is there to provide logic to operate on the data sent to and from the DAO and the client. Very often these 2 pieces will be bundled together into the same module, and occasionally into the same code, but you'll still see them as distinct logical entities.

This may helpful to you

https://softwareengineering.stackexchange.com/questions/220909/service-layer-vs-dao-why-both

Nishan Dhungana
  • 831
  • 3
  • 11
  • 30
1

DAO is as light and exists solely to provide a connection to the DB, sometimes abstracted so different DB backends can be used.

The service layer is there to provide logic to operate on the data sent to and from the DAO and the client. Very often these 2 pieces will be bundled together into the same module, and occasionally into the same code, but you'll still see them as distinct logical entities.

Yes you can implement without service layer but will lack the security.. and without using service layer the request and response works faster...

Another reason for Service layer is security - If you provide a service layer that has no relation to the DB, then is it more difficult to gain access to the DB from the client except through the service. If the DB cannot be accessed directly from the client (and there is no trivial DAO module acting as the service) then all an attacker who has taken over the client can do is attempt to hack the service layer as well before he gets all but the most sanitised access to your data.

As these answer is already answered on StackExchange.. by gbjbaanb

Rohan Shukla
  • 533
  • 1
  • 4
  • 16