Polymorphism
Domain: Design Principles
π― Motivation
Polymorphism lets different types respond to the same method call in their own way. This lets you write generic code that works with any compatible type, reducing duplication.
π Concrete Example
A speak() method on Dog returns βwoofβ and on Cat returns βmeowβ. A loop calling animal.speak() over a list works for any animal subclass without conditionals.
π Analogy
A universal remote has a βplayβ button that works on any TV brand. The remote does not care if it is Sony or Samsung β each TV knows how to respond to βplayβ.