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
- With a view to the future - it is not a fact that the rest controller will always be the trigger for dumping
- In the service layer, you can do some validation and processing of validation results
- Logging through the service