4 ms·
I feel like classic object oriented tutorials talking about fruits and apples with no connection to actual apps you'd build are ones to add to this pile
by ilyt 3y ago
I feel like classic object oriented tutorials talking about fruits and apples with no connection to actual apps you'd build are ones to add to this pile
- nyrikki 3y agoI may be wrong on this but weren't the fruit analogies originally meant to describe the difference between class based and prototype based languages and then it was extended to actually teach the concepts in a way that didn't work? I remember my professor using them to try and teach pre-standard C++ and when I pressed him to explain actual use cases I figured out he didn't understand himself. I have the feeling it was meant as a bridge for lisp programmers moving to class based languages but that may be because we learned lisp first. Anyways that context is the only place I found value in it.
- deleted 3y ago[deleted]
- crabmusket 3y agoComing up with good examples of inheritance is hard. Instead of teaching with bad examples, that should have been a warning that inheritance should be much less commonly used.
- deleted 3y ago[deleted]
- Clubber 3y ago>Instead of teaching with bad examples, that should have been a warning that inheritance should be much less commonly used. This. I think the most of the tech industry would benefit from this lesson. If it's beneficial in your situation, use it, otherwise don't. 90% of programming is linear instructions, one after the other. It's not that complicated.
- manmal 3y agoComing up with protocol oriented programming was probably one of the bigger disservices Apple has done its developers. There are still people who think everything needs a protocol, or it isn’t soundly structured.
- MrVandemar 3y agoIn the same vein, I'd love to see more articles about recursion that don't even mention, let alone demonstrate, solving factorials. There's gotta be something else.
- mplanchard 3y agoTrees or graphs would be great! Or arbitrarily nested objects. Those things have probably represented 90% of the recursive functions I’ve actually written
- delta_p_delta_x 3y agoOr parsing. One of the most intuitive and elegant real-world uses of recursion. I've been writing an XML parser and everything is recursive. Of course, because XML is fundamentally a recursive data structure, a tree. Who in their right mind would sincerely reach for a recursion to solve factorials or Fibonacci first? Even the maths-minded people would write the sequence bottom-up, and stop when it reached their desired T(n); when programming it, they'd ask for a loop-esque construct that they could stop when a condition was reached.
- MrVandemar 3y agoTree's would be great, and an actual example would be threaded comments in a forum, or just nested lists.
- rcurry 3y agoOh man, who can forget the interview questions back in the nineties. I go to an interview after spending all week writing trading systems in C++ and it’s always “let’s say you are building a car, how would you structure the classes?” LMAO, I always failed. Good times.
- shrimp_emoji 3y agoReading that made me cringe. I'd make the `Tire` class derive the `SteeringWheel` class, and `Tire::turn()` moves the car while `SteeringWheel::turn()` steers the car.
- up2isomorphism 3y agoActually these are not bad examples per se if what you want is to understand objects oriented concepts, the problem is that for many scenarios OOP is just a bad model for them.