Further Reading: Inheritance, Polymorphism, and Virtual Methods
Free Pascal and Object Pascal Documentation
-
Free Pascal Reference Guide, Chapter 6: Classes https://www.freepascal.org/docs-html/ref/refch6.html The authoritative reference for class declarations, inheritance syntax, visibility specifiers, virtual/override/abstract/reintroduce keywords, and class references. Essential for understanding the exact semantics.
-
Free Pascal Reference Guide: Virtual Methods https://www.freepascal.org/docs-html/ref/refse47.html Detailed explanation of virtual method tables (VMTs), dynamic method tables (DMTs), and the difference between
virtualanddynamickeywords. -
Lazarus Wiki: Object Pascal Introduction https://wiki.freepascal.org/Object_Pascal_Introduction A gentler introduction to Object Pascal features including classes, inheritance, and polymorphism, with practical examples.
Books
-
Marco Cantu, Object Pascal Handbook (latest edition) The definitive modern reference for Object Pascal as used in Delphi and Free Pascal. Chapters on classes, inheritance, polymorphism, and interfaces are particularly thorough. Covers advanced topics like class helpers and generics that build on this chapter's foundations.
-
Niklaus Wirth, Algorithms + Data Structures = Programs (1976) The classic that inspired our Theme 5. While Wirth's original Pascal did not have classes, the principles of data abstraction he articulated directly informed the design of Object Pascal. Understanding Wirth's thinking enriches your appreciation of why Pascal evolved as it did.
-
Bertrand Meyer, Object-Oriented Software Construction (2nd edition, 1997) The most rigorous treatment of OOP principles, including the Open/Closed Principle, design by contract, and inheritance taxonomy. Meyer's language (Eiffel) influenced Object Pascal's class model.
-
Robert C. Martin, Clean Architecture (2017) Practical guidance on the SOLID principles (including the Liskov Substitution Principle) with language-agnostic examples. Chapter 9 on LSP is particularly relevant to this chapter.
Articles and Papers
-
Barbara Liskov and Jeannette Wing, "A Behavioral Notion of Subtyping" (1994) ACM Transactions on Programming Languages and Systems, 16(6):1811-1841. The formal paper defining the Liskov Substitution Principle. Rigorous but readable for anyone comfortable with the concepts in this chapter.
-
Robert C. Martin, "The Liskov Substitution Principle" (1996) https://web.archive.org/web/2015/http://www.objectmentor.com/resources/articles/lsp.pdf A practitioner-oriented explanation of LSP with the classic Rectangle/Square example discussed in this chapter.
Design Patterns
-
Erich Gamma et al., Design Patterns: Elements of Reusable Object-Oriented Software (1994) The "Gang of Four" book. Many patterns (Template Method, Strategy, Factory Method, Observer) build directly on inheritance and polymorphism. Now that you understand virtual methods and abstract classes, you are ready for at least half the patterns in this book.
-
Template Method Pattern https://refactoring.guru/design-patterns/template-method Clear explanation with diagrams. You encountered this pattern in Section 17.9 — a non-virtual method that calls virtual methods to let subclasses customize steps.
Video Tutorials
- "Object Pascal OOP" series on the Free Pascal/Lazarus YouTube channel Practical walk-throughs of class creation, inheritance, and polymorphism in Free Pascal with the Lazarus IDE.
What Comes Next
-
Chapter 18 extends inheritance with interfaces — multiple contracts without multiple inheritance. The
IExportableandIInteractableinterfaces will add new dimensions to both PennyWise and Crypts of Pascalia. -
Chapter 20 introduces generics (
TList<T>), which combine with inheritance to create type-safe polymorphic collections — solving the "array of TGameEntity" pattern more elegantly. -
Chapter 21 covers advanced Object Pascal features: operator overloading, class helpers, and advanced RTTI — all of which build on the inheritance and polymorphism foundations established here.