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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)