CHAPTER 7

image

Inheritance Alternatives

C++ permits “multiple inheritance.” We’ll cover this next. Java simplified C++ and multiple inheritance was one of the advanced features it left out. In its place, Java featured “interfaces,” originally documented as a sort of poor man’s substitute for multiple inheritance, but in the end they proved far more valuable. (In Chapter 5, you saw that interfaces are now commonly cited as one of the main OOP concepts. Multiple inheritance is not.) I extend interfaces to “capabilities” which borrow from and extend both Java’s interfaces and JavaScript’s “mixins.” Capabilities also allow a convenient replacement for ...

Get JavaScript Object Programming 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.