I have a multiple services in my layer service, i have to execute some methods but each method in different service.
MyLastService
have a lot of functions and Autowired services example of my MyLastService
service :
@Service
class MyLastServiceImp implement MyLastService{
@Autowired
ProductService productService;
@Autowired
OrderService orderService;
@Autowired
UserService userService;
@Autowired
ReferentialService referentialService;
void addNewOrder(MyRequest req) {
try {
Product p = productService.findProduct(req.getProductId());
User u = userService.findUserByUserName(req.getUserName());
City c = referentialService.findCity(req.getCity());
orderService.addOrder(p, u, c);
}
catch(Exception e) {
LOGGER.error("error : {}", e.getMessage());
}
}
}
I am not satisfied with this implementation, beacause i will have a lot of other services and make all in one service MyLastService
can make my code difficult to read and maintenable. That why i search currently a design pattern for my application.
What can happen to MyLastService
if i put all other services into him ?
My idea now is to add new layer but i don't know what ?
Any one can propose to me the best practice for this use case ?
Aucun commentaire:
Enregistrer un commentaire