6 ms·
I disagree. OOP is not a difficult concept and not hard to teach. For an example of what happens when "OOP must not be taught to beginners", see PHP.
by TazeTSchnitzel 13y ago
I disagree. OOP is not a difficult concept and not hard to teach. For an example of what happens when "OOP must not be taught to beginners", see PHP.
- Pitarou 13y agoTrying to scare us with the PHP bogeyman? Shame on you!
- Joeri 13y agoAh, but what is php popular for other than "it's easy to get started in"? The focus on procedural programming is why people flock to it, because those objects really do make things more complicated.
- TazeTSchnitzel 13y agoBut they don't. In practice, the difference is between: $x = new Object; $x->bar($foo); vs. $x = object_create(); object_bar($x, $foo): See, for example, the "procedural" version of MySQLi.
- programminggeek 13y agoPHP for the longest time wasn't OOP at all and most of it really isn't. An awful lot of what you do with PHP has nothing to do with OOP at all.
- TazeTSchnitzel 13y agoI am aware. I use it as an example because plenty of good API designs for it that could've made it in did not because of "OOP shouldn't be used by beginners". The PHP community is unreasonably scared of OOP.
- oneeyedpigeon 13y agoWhy do you put avoidance of OOP down to fear? Maybe it's down to an understanding that OOP is often overused and should not be the paradigm-by-default. Disclaimer: I don't actually know what the cause is in this case, nor do I think that OOP should always be avoided.
- TillE 13y agoOOP "for beginners" always seems to be taught as some godawful real world analogy. It's probably easier to talk about it if you've done a little imperative programming and can grasp OOP as a solution to actual problems, rather than just some abstract nonsense.
- purringmeow 13y agoIt isn't. I took a course in my last year at high school and real world analogies made OOP seem a breeze. Almost no one in the course had problems grasping OOP basics and applying them. Of course, the OOP lectures came after 3 months of intensive studying and basic algo tasks solving.
- gavinpc 13y ago> some godawful real world analogy. Yes, I think this is a real distraction. This Cat/Dog/Animal trope leads to the view that you should use classes to model your domain objects. In some cases, you should. But this can cause as many problems as it solves, and should not (IMO) be the default approach. In getting away from this view, I've found it helpful to think of most programming as designing DSL's. To that end, you can use OO to build the infrastructure necessary to support this. But I worked in OO languages for many years before grokking that.
- n1ghtmare_ 13y agoWe'll php didn't start out as an OO language. Many of the OO "features" we're added later. Just saying (not really disagreeing).
- Goladus 13y agoFirst, I disagree with your premise that PHP's flaws can be attributed primarily to lack of OO design. But regardless: For all its (many) flaws, PHP was (and is) an extraordinarily successful project relative to the vast majority of programming projects attempted. This is in fact a confirmation of the original post's thesis. The theory is that teaching OOP to beginners bogs them down worrying about the architecture of their code before they've had any experience solving problems at the scale where the architecture matters. It's easy for a beginning programmer to waste hours on pointless refactoring that doesn't actually improve their program in any meaningful way, simply in order to appeal to some professor, teacher, or other religious figure's concept of "good code". PHP, on the other hand, said "screw you religous types, we're just going to design a product people will use." The reason that OOP should not be taught to beginners is not because it's a difficult concept. The reason OOP should not be taught to beginners is that it is an advanced concept. There are many other important fundamentals that can come first.
- TazeTSchnitzel 13y ago>First, I disagree with your premise that PHP's flaws can be attributed primarily to lack of OO design. That's not my premise. I just point to PHP (and its community) as it has some examples of it. >The reason OOP should not be taught to beginners is that it is an advanced concept. I've never quite got this. Spend any time writing code that's not using classes and you end up reinventing OOP anyway.
- jiggy2011 13y agoIt's true that if you make programming more difficult to learn then you will self-select only programmers who are especially dedicated or intelligent. I've never quite got this. Spend any time writing code that's not using classes and you end up reinventing OOP anyway. I think that letting beginners rediscover this for themselves and then exposing language constructs that make this easier probably allows a smoother path to enlightenment. It's often not obvious to beginners why copy-pasting code a bunch of times is bad compared to using loops and functions for example. It certainly wasn't for me, until I tried to build a program that was not highly trivial.