What naming convention do you use for the service layer in a Spring MVC application? [closed]

Here is what we use:

  • XxxDAO (Data Access Object) - Responsible for interacting directly with the EntityManager , JDBC DataSource , file system, etc. Should contain only persistence logic, such as SQL or JPA-QL, but not (or as little as possible) business logic. Should be accessed only from Managers.
  • XxxManager - Manages entites at the business level, usually performs CRUD operations, but adds the required business logic.
  • XxxService - The layer where the business logic resides. Should "speak" in simple objects - Strings, ints, etc. - as much as possible.
  • XxxController - The UI interaction layer. Should speak to Services only.
  • XxxUtilities/XxxUtils - Helper stateless methods, should not depend on any service in the system. If you need such sependency, either convert the utility class to a service or add the service result as a parameter.

For the implementation we add the Impl Suffix (XxxServiceImpl), to distinct it from the interface, and if there are several implementations or we want to add additional information we add it as prefix (JdbcXxxDaoImpl, GoogleMapsGeocodingServiceImpl, etc.). The classes names become a bit long this way, but they are very descriptive and self documenting.


Spring itself gives interfaces generic names and then names the classes based on the details of the implementation. This is one example that comes in mind:

interface: Controller
abstract classes: AbstractController, AbstractCommandController, 
                  SimpleFormController, MultiActionController

I don't think names like SimpleUserAccountManager or UserAccountDbManager are stupid, since they convey some information regarding the implementation of the manager/service.

What I find stupid is the common convention to add the "Impl" suffix at the implementation classes:

my/package/UserAccountManager
my/package/impl/UserAccountManagerImpl

Some people prefer this though.