Extending by Subclassing

When you create a new class, you should ensure that it is a logical and consistent extension of the class you extend, as Chapter 7, Introducing Responsibility, explores. A Java compiler will enforce certain aspects of consistency.

CHALLENGE 26.3What four aspects of the model in Figure 26.4 will a Java compiler take exception to?
Figure 26.4. What's wrong with this picture?

A Java compiler helps to ensure the consistency of your classes, but many potential extension problems will elude a compiler. In particular, class names have a meaning in English that only human-level intelligence can appreciate. For example, an overt ...

Get Design Patterns Java™ Workbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.