flâneur — a map of the web's best reading

Object-Oriented Design and Data Structures

andrewcmyers.github.io · 26 words · saved by 1 readers

We now discuss the third of these, inheritance. Inheritance is a mechanism that supports extensibility and reuse of code, both across programs and within programs. Suppose someone gives us an implementation of the Board interface that we saw in the previous lecture. In the ABoard implementation, the game state is represented by a 2D array of integers: Now suppose that we want to build a better game implementation by reusing this code. For example, we might want the game to log all of the moves that have been made. We could proceed by copying the code of ABoard to create a new class LogBoard, which we could then add new fields and methods to. But this strategy doesn't work very well when the original supplier of ABoard fixes some bugs and gives us a new version ABoard'. Now we have to either apply the same bug fixes to LogBoard on the code that we copied from ABoard to get a new LogBoard', or start afresh from ABoard' and build a new LogBoard' from it. Either way, it will be a lot of wo

Object-Oriented Design and Data Structures Object-Oriented Design and Data Structures This space unintentionally left blank...loading To provide feedback or corrections, please use the GitHub repository .

Explore this link on the map →

related reading