title: Java inheritance vs initialization
body: <p>I'm reading J. Bloch's <em>Effective Java</em> and now I'm at inheritance vs composition section. As far as I understood he said that inheritance is not always good.</p>
  
  <blockquote>
    <p>A related cause of fragility in subclasses is that their superclass
    can acquire new methods in subsequent releases. Suppose a program
    depends for its security on the fact that all elements inserted into
    some collection satisfy some predicate. This can be guaranteed <strong>by</strong>
    <strong>subclassing the collection and overriding each method capable of</strong>
    <strong>adding an element to ensure that the predicate is satisfied before</strong>
    <strong>adding the element</strong>. This works fine until <strong>a new method</strong> capable of
    inserting an element <strong>is added to the superclass</strong> in a subsequent
    release.</p>
  </blockquote>
  
  <p>But why doesn't it work? The superclass is just the <code>Collection</code> interface and if we add a new method we just a compile-time error. That's not harmful ever...</p>