5 ms·
> the multiple class abstraction is itself an obstacle to accomplishing the goal. Not if your goal is to learn about object orientated programming! > I can't
by dools 3y ago
> the multiple class abstraction is itself an obstacle to accomplishing the goal.
Not if your goal is to learn about object orientated programming!
> I can't tell you how many times students have gotten frustrated trying to understand why you have to pass arguments into the constructor or, for that matter, Why the constructor is different from other method calls. "But we already said 'drivetrain' in the constructor, and over here in this other class. Why do we have to say m_drivetrain in the class also and do m_drivetrain = drivetrain?" And there isn't actually a better answer than "in other languages that learned from Java's mistakes, you don't. But we happen to be using a language that dates back to when Animaniacs was teaching kids the names all the countries, so some parts are just bad."
Do they also have nervous breakdowns every time the spell or read the word "knight"? The etymology of a language can be interesting, and they're welcome to look it up on their own time, but the sooner they learn that all of these decisions are arbitrary, the better.
When I was first learning how to use FreeBSD I was equally confounded by trying to apply logic and reason to how the commands looked and worked. Once I just accepted the fact that it was no different to questioning why the buttons were on the left side of the toaster rather than right side, or why sought and sort are two different words pronounced the same my life got a whole lot easier.
When I'm teaching kids about code and they ask "why ... " it's an opportunity for them to learn that oh-so-important lesson that in almost all cases the design decisions in software are totally arbitrary or of such obscure etymological origin that, unless you actually want to be a computer science historian, the best answer is "because".
- shadowgovt 3y agoThey're students, of course they ask why. And while nobody had a nervous breakdown, yes, the need to pass references around extremely redundantly because this language lacks any way to establish a global context and top level non-class variables was a continuous impediment to their ability to accomplish the task. I've seen some good suggestions in this topic though; I think next year I may recommend a top-level container class that has init called on it one time and can then be referenced in all other class files. It's the closest thing to global variables Java has to offer, and would save them a lot of hardship passing references around for no other reason than passing references around.
- dools 3y agoRight, yeah that sounds like the task for which I typically use a Singleton: https://www.digitalocean.com/community/tutorials/java-singleton-design-pattern-best-practices-examples https://www.digitalocean.com/community/tutorials/java-single... Things like connections to databases, network resources, motors and those types of things.