Hacker News new | ask | show | jobs
by grahamburger 3702 days ago
Exactly! Ugh I hate that. "A cat can be an instance of animal, but it needs a 'meow' function" ... What?
2 comments

By oversimplifying, these examples actually obscure the lesson. It helped me to think of OOP objects as sub-variables, or even as a set of variables grouped by the first part of their name. Like a "multi-key/multi-value" hash table.

The purpose of functions only started making sense after learning calculus and the replacement method, where a complex term was replaced by a single variable. This is where I learned they're mostly for readability, an adaptation to make programming easier for humans to do.

Adding a "meow" function is the wrong way to go about it. The base class just needs a protected sound function so that each derived class can set the sound in its initialization routine. So many programmers, so few who truly understand OOP.