Interfaces

Because interfaces are a special type of inheritance, the notations are similar and can cause some confusion. Earlier we said that inheritance is represented by a line with an arrowhead. An interface is also represented by a line with an arrowhead—but the arrowhead is connected to a dashed line. This notation indicates the relationship between inheritance and interfaces, but also differentiates them. Take a look at Figure 10.5, which is an abbreviated version of an example in Chapter 8, “Frameworks and Reuse: Designing with Interfaces and Abstract Classes.” The Dog class inherits from the class Mammal and implements the interface Nameable.

Figure 10.5. UML diagram of an interface relationship.

Get Object-Oriented Thought Process, The, Second Edition 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.