
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
232
|
Chapter 8: Interfaces
That works in the technical sense but does nothing to suggest to the developer that
event-consumer objects must implement one of the application’s event-listener inter-
faces. By forcing event-consumer objects to implement the marker interface,
EventListener, the application guides the developer to the documentation for that
interface. The documentation should describe the application’s general event archi-
tecture, helping the developer understand how to properly handle events. This sys-
tem is a native part of Java. We’ll return to it in Chapter 19.
Multiple Type Inheritance with Interfaces
In our earlier order-form example, we learned that a class can inherit from another
class while also belonging to a separate datatype defined by an interface. Our earlier
OrderUI class inherited from MovieClip but also belonged to the OrderListener
datatype because it implemented the OrderListener interface. That architectural pat-
tern is one of the more common and powerful uses of interfaces—one in which a
class belongs to multiple datatypes without inheriting from multiple classes. Let’s
take a closer look at this pattern with a new example (source code available at: http://
moock.org/eas2/examples).
Suppose we’re creating an application that stores objects on disk,