3 ms·
> The essence of OOP is not inheritance, that’s a nice to have. The essence of OOP is to encapsulate the data and the functions that operate on that data into a
by rualca 5y ago
> The essence of OOP is not inheritance, that’s a nice to have. The essence of OOP is to encapsulate the data and the functions that operate on that data into an object and hide the internal state of the object from the rest of the program.
What is inheritance but a way to encapsulate data and methods in a way where you only need to override a subset of very specific methods and/or data to specialize an implementation?
- ratww 5y agoInheritance is a bit more complicated than that. Your definition is closer to what the Template Method pattern [1] is, rather than inheritance in general. Keep in mind also that neither inheritance itself nor the Template Method pattern guarantee encapsulation. [1] https://en.wikipedia.org/wiki/Template_method_pattern https://en.wikipedia.org/wiki/Template_method_pattern