3 ms·
OOP is encapsulation, inheritance, and polymorphism. Polymorphism maps to behaviour which is type-based, but usually also based on the objects internal/mutable
by karmakaze 2y ago
OOP is encapsulation, inheritance, and polymorphism. Polymorphism maps to behaviour which is type-based, but usually also based on the objects internal/mutable state. This is no surprise since OOP came out of Simula for doing simulations.
- vips7L 2y agoI really disagree. You don’t need polymorphism or inheritance. The core of OOP is objects and encapsulation. Putting behaviour next to the data. It has nothing to do with mutability.
- layer8 2y agoReferring to my GP comment, subtyping subsumes inheritance and polymorphism. It is orthogonal to mutability. As an illustrative example, the Java Collection Framework makes significant use of inheritance and polymorphism, but could as well be reduced to immutable collections.