5 ms·
Well, most OOP isn't object oriented at all, it's class oriented or maybe another way to look at it is that most of the time OOP is used as containers for data
by programminggeek 14y ago
Well, most OOP isn't object oriented at all, it's class oriented or maybe another way to look at it is that most of the time OOP is used as containers for data and function, not for things.
For example, say you have an object that holds some strings and numbers and it has getters and setters on it. How is that different than a Hash? Is that object oriented? If you add a couple helper methods to said object is it more OOP if you still are using getters and setters?
There is a fundamental difference between treating OOP as a bunch of classes that contain basically procedural code vs treating them as objects that are things that do things.
Treated the way it often is, OOP is not that useful for anything other than namespacing and creating ridiculous hierarchy structures just because "it's oop" and inheritance lets humans do what they love to do - name and categorize things.
If you treat objects in OOP as "things", I think it is more useful and interesting than treating objects as containers. Either way, not all code needs to be OOP at all.
- guelo 14y ago> OOP is not that useful for anything other than namespacing Namespacing, and modularization in general, are cornerstones of well structured code. OOP gives you nice tools to help with this.
- ynniv 14y agoOOP gives you tools. Having spent the last 15 years using them, I'm not convinced they are nice.
- seanmcdirmid 14y agoAgreed, OOP tools are the worst, except when compared to FP tooling. PL tooling just sucks in general.
- lerouxb 14y agoMaybe you use C++, Java or one of the languages in that family?
- regularfry 14y agoNamespacing and modularisation are completely orthogonal to OOP. It just happens that recent languages sold as "OOP" have namespaces and modules.
- hackinthebochs 14y ago>For example, say you have an object that holds some strings and numbers and it has getters and setters on it. How is that different than a Hash? Of course this is the most degenerate case of an object, so pointing to this as an counter-argument to OOP seems rather specious. The typical case is that the data being encapsulated is related to each other in some way, and thus having a restricted set of operations on the object can ensure certain invariants are maintained. You cannot duplicate this with just a standard hash. >and inheritance lets humans do what they love to do - name and categorize things. You say that like its a bad thing. If humans like to categorize, why shouldn't our programming languages be designed around this tendency?
- gridaphobe 14y ago> You say that like its a bad thing. If humans like to categorize, why shouldn't our programming languages be designed around this tendency? I've always had the impression that we (at least as programmers) are incredibly bad at categorizing things into hierarchies. I think class hierarchies (and module hierarchies for that matter) suffer from a similar problem to that of hierarchical file systems, there is often more than one way of organizing the items and it's unclear which way is right. I'd like to see if one could use a tagging mechanism instead; I guess interfaces/mixins/traits could be thought of as tags for classes though.
- ionforce 14y agoIsn't that what interfaces are?
- jeffdavis 14y agoYou and the author appear to be using different definitions. I find it troubling that, after all this time, there is still no definition that doesn't use words like "thing".
- gdwatson 14y agoI like the Rees OO ontology[1]. The set notation doesn't lend itself to easy reading, but it lets you break out the features of an object system in a more precise way. [1] http://mumble.net/~jar/articles/oo.html http://mumble.net/~jar/articles/oo.html
- jeffdavis 14y agoI have seen that before and I don't consider it particularly useful. #5 is self-referential and useless. Only one or two (#9 and maybe #7) of those help distinguish OOP style from anything else, and #9 is not very compelling. When I see OO code, I mostly think about the bundling of code with the data it operates on, but that is basically a module. So maybe it should be called module-oriented programming?
- stcredzero 14y ago> Treated the way it often is, OOP is not that useful for anything other than namespacing and creating ridiculous hierarchy structures just because "it's oop" and inheritance lets humans do what they love to do - name and categorize things. Leave out inheritance, but keep interfaces, and you get better OOP.
- cwbrandsma 14y agoYes, then you get VB6. Not sure that is the paragon of language design you are looking for. Inheritance is a very useful tool, but like many other things, overuse of inheritance is worse than not using it at all.
- stcredzero 14y agoYes, then you get VB6. Not sure that is the paragon of language design you are looking for. Most of the qualities that make VB6 VB have nothing to do with inheritance. This is a logical fallacy, where you argue by associating one quality with something looked down upon. http://en.wikipedia.org/wiki/Association_fallacy http://en.wikipedia.org/wiki/Association_fallacy