Inheritance in Object-Oriented Development

Inheritance provides a mechanism for reuse. Inheritance, as a mechanism for code reuse, was probably a significant factor in making object-oriented programming attractive in the 1980s and early 1990s. However, good object-oriented design calls for inheritance to be used in a very disciplined way—that is, in accordance with the substitution principle (see Substitution Principle on page 33). Under that discipline, inheritance is a mechanism for interface reuse instead of code reuse.[1] In our discussions in this chapter, we assume inheritance is used only in accordance with the substitution principle. Under that assumption, the set of test cases identified for a class is valid for a subclass of that class. ...

Get A Practical Guide to Testing Object-Oriented Software 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.