3 ms·
This is a good point. Because you can't make a car or an animal out of software these analogies always seem to lead to bad teaching. Much better to use somethi
by Alex3917 11y ago
This is a good point. Because you can't make a car or an animal out of software these analogies always seem to lead to bad teaching.
Much better to use something like Person and Employee/Student, where it's easy to immediately grasp the value based on not having to duplicate the data fields you'd need for a basic CRM. (As opposed to having to make up ridiculous methods about the panda eating bamboo or whatever where no one understands what the fuck is going on.)
- grahamburger 11y agoExactly! Ugh I hate that. "A cat can be an instance of animal, but it needs a 'meow' function" ... What?
- stephengillie 11y agoBy 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.
- BatFastard 11y agoAdding 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.
- deleted 11y ago[deleted]