'Spring boot service layer interface + implementation pattern

In a typical CRUD application we could have entities such as users, orders, invoices etc.

For the service layer it's a common pattern to create the service interface and its implementation.

  • UserService
  • UserServiceImpl
  • OrderService
  • OrderServiceImpl
  • InvoiceService
  • InvoiceServiceImpl

I know it's a good practice to code in terms of interfaces, but for this particular case where the service implementation most probably won't change, do we really have to create an interface and its implementation with that ugly "Impl" suffix?

It might be that I just have a problem with that naming convention? Is there another way to address the design and creation of the service layer?

This might be a slightly different approach in the naming convention:

  • UserService
  • DefaultUserService
  • OrderService
  • DefaultOrderService
  • InvoiceService
  • DefaultInvoiceService

However, I feel that we are still coding in terms of interfaces "just" for the sake of coding in terms of interfaces in a situation where the implementations most probably won't change.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source