jeudi 30 juin 2022

spring boot fat service refactoring

I have a very fat class which hold the code business logic of my application - the class is using other service and sometimes other service's repositories to get data needed for its actions.

the entities in my application are just POJO.

So lets assume the service is InventoryService and it has 200 methods that we want to split up, and its uses the Product, Tax, Customer entities.

would it make more sense to transfer the business logic to the entities themselves to reduce the code on the service level? or rather add more services such as ProductInventoryService, TaxInventoryService and etc.. and move some of the logic to them?

any practical examples would be appreciated, the basic design of the app is controller >service >repository where we aim to use Entities between all layers and return DTO to the client from the controller. Thanks

Aucun commentaire:

Enregistrer un commentaire