English
Summary
Conclusions
Inheritance defines a relationship between types and can reuse an implementation. Polymorphism lets a client work with a shared role. ABC makes some requirements explicit at instantiation, while Protocol describes a structural contract for an analyzer. MRO defines lookup order, and composition allows independent replacement of parts of behavior. Design is verified through substitution and contract tests, not merely a correctly drawn arrow.
Self-check questions
- How do you declare a derived class and call base initialization?
- What does
supermean in multiple inheritance? - How does
isinstancediffer from an exact type check? - What problem does a polymorphic loop solve?
- Why is a matching method name insufficient for a contract?
- When does ABC prevent creating an instance?
- How do you declare an abstract property?
- What is a template method?
- How does nominal typing differ from structural typing?
- What does
runtime_checkablenot check? - What does
registerchange, and what stays unchanged? - What guarantees do
overrideandfinalprovide at runtime? - How does C3 order a diamond hierarchy?
- What contract should a mixin have?
- When can a square not substitute for a mutable rectangle?