Home > Enterprise >  Do I really need a service layer/classes along with springboot RestController if I'm not adding
Do I really need a service layer/classes along with springboot RestController if I'm not adding

Time:11-14

I understand that it is advisable to add Service along with Controller classes keeping the best practices in the mind. Say, if I have to create a dump-api which is responsible to dump all inbound data on Kafka topic in the Kafka cluster without any logic. I believe best practices are meant to get the best out of an application, and I believe skipping service layer is serving the purpose.

So, do I really need service layer in this case since I have to make my application light-weight?

I tried reading some blogs on best practices and architectural blogs (on lightweight and performance talk) but didn't find my answer.

CodePudding user response:

In our projects, we try to always implement a service layer

  1. With a view to the future - it is not a fact that the rest controller will always be the trigger for dumping
  2. In the service layer, you can do some validation and processing of validation results
  3. Logging through the service
  • Related