March 2002
Intermediate to advanced
496 pages
8h 51m
English
New classes should be logical, consistent extensions of their superclasses, but what does it mean to be logical and consistent? A Java compiler will ensure a certain level of consistency, but many principles of consistency will elude a compiler. One principle you should consider in your designs is the Liskov Substitution Principle (LSP). This principle, documented in Liskov (1987), can be paraphrased: An instance of a class should function as an instance of its superclass.
Basic LSP compliance is built into OO languages, such as Java. For example, it is legal to refer to a Rocket object as a Firework, as Rocket is a subclass of Firework:
Firework f = new Rocket();
Some aspects of LSP compliance require human-level ...
Read now
Unlock full access