4 ms·
As a Python instructor, classes are a pain in general to teach. OO seems to have a non-understandable aura around it. Especially for folks without a CS backgrou
by __mharrison__ 4y ago
As a Python instructor, classes are a pain in general to teach. OO seems to have a non-understandable aura around it. Especially for folks without a CS background. self is weird until you explain that __init__ is not really a constructor. We get through it but there are bumps in the road.
I don't teach dataclasses until I teach intermediate classes because I like my students to understand decorators beforehand.
This make me wonder if I should experiment with teaching dataclasses instead of __init__ (and just hand-wave decorators and types)...
- sireat 4y agoI've been a Python instructor for 5+ years and I've never taught to my students that __init__ is not a constructor. That is I teach that __init__ works just like a constructor. Sure technically (the best type of correct) it is not a constructor. Where would this be important? Maybe it could be taught as part of "language lawyer" course. I teach OOP around lesson 10. Each lesson is about 2hours. Complete beginnners to programming are able create basic classes and even inheritance. Some people like OOP some stick with imperative style. Some migrate to more functional style (which I personally advocate). Going through this old thread: https://stackoverflow.com/questions/6578487/init-as-a-constructor https://stackoverflow.com/questions/6578487/init-as-a-constr... puts me firmly into "this is hair-spliting" camp.
- bmelton 4y ago> Where would this be important FAANG interviews? Knowing that __new__() comes before __init__() is probably useful, as the deeper one gets into a language the more important it is to understand the lifecycle of an object. Otherwise, the only thing I can think of that's special is understanding that and how it works as a singleton.
- gautamdivgi 4y agoI’ve been through a couple of those. I’ve never been asked language specific questions. Most FAANG code interviews don’t care much about which language you choose. I’ve also not seen them care if you use OO or don’t. Either way works - as long as your algorithm is good. In short this is irrelevant for those interviews. It’s definitely relevant if you do python as a day job.
- PreachSoup 4y agoNo, it's the opposite. Big tech don't care about these. Internally their language style are as generic as possible. They want you to avoid warts and gotchas and make every oop language usage look the same so that you can actually jump around different the projects
- kortex 4y agoI think that muddies the water a bit too much and relies on too much magic. Self might be weird, but it's one of the most central concepts in python. Especially if someone is coming from javascript. Dataclasses don't quite follow the same rules as regular classes, especially with inheritance. I think waiting to understand decorators is a good call.
- falcor84 4y agoOn a side note, I absolutely love how your username itself is a dunder identifier, well played!
- deleted 4y ago[deleted]