title: Visitor Pattern or polymorphism?
body: <p>I have a polymorphism structure in my project, and thinking of if it could be valuable to rewrite it to use <code>Visitor Pattern</code>.</p>
  
  <p>The basic structure is: I have some drawing objects <code>(Rectangle, Ellipse, Line</code>, more to come) that have of course some behavior in common. The behavior is defined by the interface <code>Drawable</code>.
  So far, dragging should always behave the same, but drawing them selected should differ.</p>
  
  <p>I therefore introduced the <code>abstract Figure</code> class, which already implements <code>drag()</code>, but delegates the implementation of <code>drawSelected()</code> to the extending classes.</p>
  
  <p>Of course the interface will later be extended with additional functions I need, and also additional implementations of Figures will come.</p>
  
  <p>Now my question: Would your rather stick to this design, or switch to <code>Visitor</code>. And if so, why?
  Especially I'm not sure if my present approach is good to have the logic/algorithms for drawing selections inside the objects itself.</p>
  
  <pre><code>interface Drawable {
      void drag();
      void drawSelected();
  }
  
  
  abstract class Figure implements Drawable {
      protected int x, y, w, h;
  
      @Override
      void drag() {
          //implementation always the same for different figures
      }
  }
  
  
  class Rectangle extends Figure {
      @Override
      drawSelected() {
          //draw a dashed rectangle around this object
      }
  }
  
  class Ellipse extends Figure {
      @Override
      drawSelected() {
          //draw a dashed ellipse around this object
      }
  }
  
  class Line extends Figure {
      @Override
      drawSelected() {
          //draw the line itself dashed
      }
  }
  </code></pre>