title: Anonymous vs named inner classes? - best practices?
body: <p>I have a class, let's call it LineGraph, that renders a line graph. I need to subclass it, but the derived class is only used in one place and is coupled to the class that uses it. So I am using an inner class.</p>
  
  <p>I see two ways to do this:</p>
  
  <p><strong>Anonymous inner class</strong></p>
  
  <pre><code>public class Gui {
      LineGraph graph = new LineGraph() {
          // extra functionality here.
      };
  }
  </code></pre>
  
  <p><strong>Named inner class</strong></p>
  
  <pre><code>public class Gui {
      MyLineGraph graph = new MyLineGraph();
  
      private class MyLineGraph extends LineGraph {
          // extra functionality here.
      }
  }
  </code></pre>
  
  <p>I am not a fan of anonymous inner classes, because frankly I just think it looks really ugly. But in the case of a subclass that's only used in one place, is a named inner class overkill? What is the accepted practice?</p>