Polymorphism Through Shared Types
Program to a type, not a class.
What Polymorphism Means
Polymorphism lets one type stand in for many. You call a method on a shared type and each object responds in its own way.
Program to a Type
Instead of naming a concrete class, you depend on a shared supertype. Your code works with anything that fits that shape.
void render(Shape s) => print(s.area());All lessons in this course
- Abstract Classes and Abstract Methods
- Implicit Interfaces and implements
- Polymorphism Through Shared Types
- Composition Over Inheritance