title: Conventions for naming service classes
body: <p>I'm developing a simple Java application for doing CRUD operations against a database through a RESTful API. It's divided into three layers: the controller layer, the service layer and the DAO layer.</p>
  <p>Normally, I create a service interface for each domain object. Say, <code>User</code>:</p>
  <pre><code>public interface UserService {
    List&lt;User&gt; getAll();
    User create(User entity);
    void update(User entity) throws Exception;
    void delete(Long id) throws Exception;
  }
  </code></pre>
  <p>Then I implement that interface in a service class:</p>
  <pre><code>public class UserServiceImpl implements UserService { ... }
  </code></pre>
  <p>This approach I think has several drawbacks:</p>
  <ul>
  <li>It forces me to name the concrete class something other than <code>UserService</code>, although I only have one concrete implementation of that interface</li>
  <li>All the different services do not implement the same interface</li>
  <li>There's an explosion of interfaces that all behave the same way</li>
  </ul>
  <h3>Another approach</h3>
  <p>I'd create an interface that all services would implement:</p>
  <pre><code>public interface CrudService&lt;T&gt; {
    List&lt;T&gt; getAll();
    T create(T entity);
    void update(T entity) throws Exception;
    void delete(Long id) throws Exception;
  }
  </code></pre>
  <p>So I choose the name <code>CrudService</code> to convey the functionality provided by that interface. Then, I have a concrete service class implementing that interface with a type parameter <code>User</code>:</p>
  <pre><code>public class UserService implements CrudService&lt;User&gt; { ... }
  </code></pre>
  <p>This way my services have names like <code>UserService</code> which I think is more clean and readable.</p>
  <h3>Questions</h3>
  <ul>
  <li>What's the convention for naming service classes? What do you usually do?</li>
  <li>Should I name a concrete class <code>UserService</code> when that sounds like an interface?</li>
  <li>What about the <code>Impl</code> suffix? Does it convey anything about the implementation?</li>
  </ul>