4 ms·
>What do they know? They know real world. So when explaining something like for example a Superclass, you can use something like a vehicle... This is good up t
by kyle-rb 8y ago
>What do they know? They know real world. So when explaining something like for example a Superclass, you can use something like a vehicle...
This is good up to a point, and obviously it makes sense for absolute beginners. But eventually, when you understand programming, and just need to learn a new thing, it makes more sense to frame it in terms of actual use cases. I tried to read an explanation of JavaScript promises that used Shake Shack as an analogy and I think there were too many levels of indirection to understand it. Meanwhile, there's a Google developers post that explains it using image loading and that one clicked pretty much right away.
- dharmab 8y agoAs a child (circa easly 2000s) I was immensely confused by the analogies that online guides used to explain OOP. I ended up so confused that I just gave up for many years until a wonderful professor explained it to us in plain, concrete language. Analogies and use cases can help demonstrate _why_ something is useful, but can also obfuscate concepts.
- zeth___ 8y agoAbsolutely what happened to me. A class is not a car, you don't explode your car when you go off road, create a SUV using the base of the car along with what's in the trunk, then do it back again when you reach a road. Analogies are a terrible way to teach. Both dogs and cows are mammals with 4 legs and a tail, but you will have an interesting experience playing catch with a cow and trying to milk a dog. I only learned what a class is and why it matters after writing a bunch of C spaghetti code trying to keep track of special_fn_for_strings, special_fn_for_ints, special_fn_for_big_ints, etc. You can teach that way quite easily if you have more than a week to do it in.
- slobotron 8y agoSome would argue that OOP and class hierarchies are orthogonal concepts, so any analogy with biological taxonomies is bound to leave you unenlightened for a long time.
- gleenn 8y agoAnd yet sadly that almost always what authors reach for when looking to explain OOP...
- ibeckermayer 8y agoCan you go into a bit more detail about what you mean with these special fn_for_* things? I learned OOP recently with all the animal->mammal->cat analogies, however those all seem to focus on inheritance and miss the key concept which might be summarized as “managing context”. Am I on the right track here?
- Majora320 8y agoI'm not the original commenter (and on mobile, so this response might be a little terse), but I think what he's talking about is polymorpism. For an example, if you have two classes, Int and String, and you have a method special_fn you want to implement for both in different ways, (e.g. "addition/concatanation"), you can either make a bunch of special_fn_* stuff, or simply create an interface SpecialFner with the special_fn method, and implement it for Int and Str. This lets you use this interface in other places without worrying about all the different versions of this function.
- ZephyrP 8y agoI had almost exactly the (almost the exact?) same experience. I was 12 when I picked up a "Head First Java" at the library. The first chapters on for loops and variables were a breeze, but after a few more the book started a new program of loosely analogizing various function specifiers to real-world ontologies; all against the background of a writing style that emphasized that programmers can also write (and poorly photoshop) in a "WILD & ZANY STYLE THE KIDS WILL LOVE'. Yes, I'm starting to remember the trauma now: "Vehicles and Cars" or 1-Stripe Zebras vs Zebras-with-many stripes vs a Zebra with a stripes attribute... I had no problem with a for loop to print "FUGAZI SUX" 99 times, but the book wasn't communicating how these concepts were important to making a nontrivial program in Java; which I desperately wanted to do so badly. A bit later, I downloaded a book about writing computer exploits, which was very basic and very direct. Strangely, dealing with computers at this extremely basic level of stored instruction pointers, buffer overflows and assembly language actually let me gain the skills required to be an "actual programmer".
- sgift 8y ago> Strangely, dealing with computers at this extremely basic level of stored instruction pointers, buffer overflows and assembly language actually let me gain the skills required to be an "actual programmer". There is nothing strange about that. People learn in different ways. For me the Head First books were a great alternative to the scores of dry "here is fact 1. And here is proof for fact 1. Here is fact 2. Here is proof for fact 2." books, which bored me to death and didn't help me with learning.
- Matt3o12_ 8y agoPeople learn differently. For me, it was probably they best book I have ever read to learn programming. Before that I only knew PHP from web tutorials and even functions weren’t obvious to me (I knew what they did, I just almost never used them because by the time I knew what the function was, I already inadvertently reused a lot of code – I still have one of my early websites with over 2000 lines of code in a single file and only two functions with 10 lines code each! It is an absolute nightmare to read but it worked). Head first java brought all those concepts to me in a way I understood and could apply and benefit from. What you are describing is a problem I see with a lot of people who learn programming. They want to apply what they have learned in a way that is different from a few modified example. When they learn python, after chapter one or two, the most common question is: but how do I build a GUI because the command line is very foreign to them. People often don’t have enough patience, or motivation to learn a whole book and not be able to do something remotely useful. I’m glad you got into it by learning something that really interested you with computers (unfortunately this is really hard these days because everybody I know either wants to program GUIs or Games). I know some who got into programming by writing Minecraft plugins. That allowed them to apply what they learn to something really useful and fun. But I also like Apple’s approach with Swift. Children get immediate graphical feedback of what they have written. It’s certainly not something that teenagers have a lot of fun with (because “it is silly”) but children might really enjoy learning that way. Websites are probably another good example. Writing working JavaScript and html is really easy these days and a website is useful for a lot of people.
- roenxi 8y ago> This is good up to a point, and obviously it makes sense for absolute beginners. The way classes are explained with cars and animals has always struck me as extremely perverse, I've seen a couple of very bright students who were just baffled by what lesson they are meant to take away from the analogy. Consider: Vehicle is to Car as is Superclass is to Subclass. Vehicle is to Car as also is a string of bits is to a C int. Why is this analogy any more relevant to explaining class relations vs explaining that all data can be represented as a stream of bits? Or a whole list of other concepts where a thing is classified? Once the OOP vehicle-car analogy is probed past the truly superficial grammar, there isn't anything there. Classes are an organisational tool. They have more in common with database normal forms and and functional programming than cars. Representing that an organisational concept should be thought about as a physical relation is not helpful.
- howlgram 8y agoYes! There is crazy amounts of dilly dallying with these analogies and there are implied points of logic that are not to belong in the actual technical concept, especially when teachers make it a point to say "these should be separated into a superclass/subclass/attribute but these shouldn't, and it should be specific to this extent and not to the extent that you thought was fitting", while talking about cars and car parts or animals and animal parts and species etc and, there is no actual logic behind their arbitrary separation of concepts that makes sense in their mind, it could be implemented in multiple ways that work, but only the one that they thought made sense to them is correct and students get punished for not thinking like the teacher even if they did something right, this leads to the students wondering if the concepts are just too difficult and going over their head when it's not their fault at all.