title: Spring: DTO and service layer
body: <p>I'm using the current layer topology:</p>
  
  <p>1) dao
  2) service
  3) controllers(presentation)</p>
  
  <p>In one of my controllers I'm receiving the following call (from clients):</p>
  
  <pre><code>public PlayerStatisticsDTO getPlayerStatistics(int playerId);
  </code></pre>
  
  <p>The controller should now delegate the call to the service layer.</p>
  
  <p>Problem is, if i create a method like:</p>
  
  <pre><code>public PlayerStatisticsDTO getPlayerStatistics(int playerId);
  </code></pre>
  
  <p>in my Service I'm actually making my service layer aware of the DTO object!</p>
  
  <p>I believe this is a bad practice (or not?)</p>
  
  <p>So my other alternative that i came up with is creating a new class:</p>
  
  <pre><code>public class PlayerStatistics {...}
  </code></pre>
  
  <p>and then calling in my controller:</p>
  
  <pre><code> PlayerStatistics stats = this.service.getPlayerStatistics(playerID);
   return toDTO(stats);
  </code></pre>
  
  <p>The problem with this solution is that i dont have any use for this class at all in my project so it seems like an unnecessary duplicated code</p>