3 ms·
I don't know that OO's main goal is to be readable, but rather to manage complexity (which should help readability, but I don't think that's the focus). There's
by ahlatimer 16y ago
I don't know that OO's main goal is to be readable, but rather to manage complexity (which should help readability, but I don't think that's the focus). There's an inherent level of complexity in OO that isn't necessary when you're solving basic, learner type problems, but it can help keep complexity down when you're solving problems that have solutions that can't be kept in your head at any one time.
To put it differently, think of an algorithm that's constant time, but has a very large constant and an algorithm that's O(n). The constant time algorithm will be worse for small sets, but better for large sets (once n > that constant). That's the problem with teaching OO to people new to programming. You're adding an additional thing to an already difficult topic, and that thing you're adding doesn't really benefit you at that level of problem, but get to a bigger problem, and it starts to make sense.
- simpleTruth 16y agoI agree, but it's good to step back and think why that's true. The real value in OO programming is being able to reduce complexity by reusing code in a new ways. Either by creating several instances of the same object that all manage a complex internal state, or by inheriting from another object and extending functionality. I need to add a window, I already have lot's of windows, but this one is different because X works in OO. I need to build my first window starting from scratch and suddenly OO does not give you any leverage. Which is why OO seems pointless for most being programmers, they can't deal with sufficiently complex problems to gain anything from OO programming. However, you don't need to understand object's to use them. It takes a while to understand why you can keep adding <<'s after cout, but most beginners quickly prefer it over sprintf.
- raganwald 16y agoWhich is why OO seems pointless for most being programmers, they can't deal with sufficiently complex problems to gain anything from OO programming. Beware, this is not biconditional. I'm sure you won't have to go very far to find programmers who deal with complex problems but who do not feel that they gain anything from solving them using OO. And there is also the argument that OO as implemented in popular languages introduces its own complexity, such that it ends up being used to solve the problems it introduced in the first place.
- devin 16y agoComplexity comes in many flavors. One of those flavors is mutable state. Reducing that makes OOP better. You can have your meta meta, and still be sane in your reuse of existing code. Keep the object abstraction, just limit it's scope overall.