Why do we need a level of service?

I am currently studying Spring Boot, and I have seen people create a controller, implement a service class and implement a repository in a service class.

Why do we need a service class as an intermediary and why can't we just enter the repository into the controller?

Here's a lesson that confused me: https://www.youtube.com/watch?v=lpcOSXWPXTk&list=PLqq-6Pq4lTTbx8p2oCgcAQGQyqN8XeA1x

+4
source share
4 answers

You do not always need a level of service. Especially if your APIs are just simple CRUD operations, for example, without real logic or computation.

, API, , . , .

https://en.wikipedia.org/wiki/Single_responsibility_principle

  • .
  • , , .
  • .
+4

:

, , .

, - - () () .

, (, ), , , .

, ( ), , . , ...

  • 1:1
  • ( ) ( )

... , .

, ...

  • , . , .
  • ( ) ( )

... , .

+3

, , (SOLID), ( ), HTTP/REST AMQP.

.

0

Spring - , . , , -. , , API. , , .

, .

0

Source: https://habr.com/ru/post/1686459/


All Articles