title: Adding behaviour to DTO object
body: <p>This is a design question which confuses me.</p>
  
  <p>As you know, object consist of attributes and behaviours. In web programming, I have implemented several protocol objects as DTO. these are like:</p>
  
  <pre><code>abstract AbstractRequest{
  
     public abstract AbstractResponse apply();
  ...
  }
  
  MathLessonRequest extends AbstractRequest{
  
      public AbstractResponse apply(){
            ..do something based on request
      }
  ...
  }
  
  HistoryLessonRequest extends AbstractRequest{
      public AbstractResponse apply(){
            ..do something based on request
      }
  }
  </code></pre>
  
  <p>and what I want to do is , in my controller I simply want to do something like this:</p>
  
  <pre><code>@RestController
  class SchoolRequestController{
  
      @RequestMapping(value="/",method = RequestMethod.POST, produces = "application/json")
      @ResponseStatus(HttpStatus.OK)
      @ResponseBody
      public AbstractResponse query(AbstractRequest request){
  
            return request.apply();
      }
  
  }
  </code></pre>
  
  <p>So , as you can see, I want to give Request classes the responsibility to execute all what they are asked for. </p>
  
  <p>My question is , is it a good design? Is it right to give DTO objects the responsibilities to execute what they are for? Or Are DTO objects only for data transfer?</p>
  
  <p>PS:This design comes with a problem that, apply method needs some outer references of some other objects like services, dao etc. So what is the elegant way to inject this dependencies into this instances?</p>