Polymorphism
Updated 2026-07-28
Summary
The same interface can be carried by different implementations, letting a system choose the concrete behavior dynamically at runtime.
Definition
Polymorphism means that a single interface can be carried by different implementations, and the system can dynamically select which concrete behavior to execute at runtime. Its scaffolding value is designing for flexibility: it reserves room for change rather than hard-coding one specific implementation, so new variants can be added without rewriting the interface.
Introduction
How to use
- Design for flexibility: reserve room for change rather than hard-coding one specific implementation. - Swap behavior at runtime: let the system choose which concrete implementation to execute behind one interface.
Mechanism
Polymorphic composition leverages object-oriented polymorphism to encapsulate behavioral differences as replaceable implementations, combined at runtime. The mechanism is that the same interface has multiple forms, enhancing extensibility and decoupling.
Practice
In progress 0/1Practice this model in one real situation:
Cases
- Payments use a unified Payable interface, with domestic and overseas implementations hot-swappable.
Common pitfalls
- Creating useless abstractions for the sake of polymorphism, or inconsistent semantics among implementations.
Sources
Source support: Explicit
References currently contain only Wikipedia links; primary sources still need review.
- en.wikipedia.orghttps://en.wikipedia.org/wiki/Polymorphismverified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS