6 ms·
> In all my experience with OOP, it's always been inheritance that is the root of all evil. I have this "theory" in the back of my head that trees are usually
by Zababa 5y ago
> In all my experience with OOP, it's always been inheritance that is the root of all evil.
I have this "theory" in the back of my head that trees are usually the wrong things to model thing in life but it's what come to us naturally. For example, a blog with categories and sub-catogories for articles (a tree, inheritence) can often describe the content better by using tags (a graph, composition). I think that's because trees are easy to deal with and understand, but graphs are more "open" with what you can do.
- necheffa 5y agoExcept that trees are by definition graphs with specific conditions on direction and cycles.
- db48x 5y agoPerhaps it is those very conditions which make trees less useful than they at first appear.
- duped 5y agoA tree is a graph where all vertices have exactly one path through them. Trees are often implemented using composition, and inheritance can be graphical (the Diamond Problem is not game over).
- jstanley 5y agoA / \ B C / \ / \ D E F G This is clearly a tree, but doesn't B have 2 paths through it? A->B->D and A->B->E.
- gmfawcett 5y agoYou're right. The correct definition is that any two vertices are connected by (i.e. are the endpoints of) exactly one path. Fun fact -- since graph-theory trees are undirected by definition, an inheritance graph is more properly called an arborescence (for single inheritance). For multiple inheritance it's a DAG (with diamond-pattern) or a directed tree (without).
- jholman 5y ago> any two vertices are connected by (i.e. are the endpoints of) exactly one path No. You just described a connected acyclic graph, not a tree. In addition to being connected and acyclic, a tree must also have a root, and is thus implicitly directed.
- hcarvalhoalves 5y agoData modelling in OOP is an exercise in coming up with Platonic ideals, resulting in a hierarchical (tree-like) ontology as you try to choose of the atributes as the categorisation dimension, and leaving everything else as properties. class Animal class Mammal inherits Animal class Feline inherits Mammal class Cat inherits Feline ... This is different than just asserting facts with data, which can lie in multiple dimensions. Is Feline Is Mammal Is Fluffy Is White Does Meow The later is a much more flexible data model as it more closely mimics observed (subjective) reality, and is less disturbed when a new (counter-)example is introduced, but is also harder to reason about than idealised categories.
- wwweston 5y agoHence traits?
- beaconstudios 5y agoAnd ECS is fundamentally a trait system!
- dkersten 5y agoI know all the terms are overloaded nowadays so everything’s kinda unclear but I always wished that ECS components had been called traits, because adding a component to an entity gives it some a trait like “this thing has a position in the world” or “this thing can be drawn” (and perhaps have systems named “behaviors”, because systems add behavior to entities based on the traits/components that they have) Years ago, when ECS was just starting to be talked about (after Adam Matrins blog posts), I wrote a toy ECS where I used that naming convention. Nowadays I stick to the mainstream terminology since that’s what other people know.
- beaconstudios 5y agoYeah I've commented before that "entity component system" is roughly synonymous with "thing piece thing" or something like that - it's a really bad name because it's so ambiguous. Anything including the term trait would be 1000x better because at least "trait" means something.
- dexwiz 5y agoHumans have a natural tendency to refine a single idea by splitting it into two based on a differentiating factor. This ends up looking like a tree when applied repeatedly. Dichotomous keys for species identification are another example of this.
- eska 5y agoThe problem being that they don't categorize things into one tree, but many. One can view the same thing in different ways. OOP tree hierarchies do not allow that. It's like trying to categorize your photos in a directory tree. Do you categorize by year first, by person, or location? There is no correct answer. What people want instead is a photo album with tags. The same problem applies to OOP.
- setr 5y ago> What people want instead is a photo album with tags What you really want is hierarchal tags :)
- splistud 5y agoNo, no. We want tags. Later we want hierarchal tags (with some complex workarounds to maintain some legacy thing included in the implementation).
- Zababa 5y ago> It's like trying to categorize your photos in a directory tree A problem that made me think about tags instead of categories was precisely that: I have photos that I want to organize. I started by organizing them by person with a folder for each person. But how do I handle a photo where multiple people are in it? Tags don't have this problem. Unfortunately file systems don't support tags.
- btschaegg 5y agoSilly monkeys Give them thumbs, they forge a blade And where there's one they're bound to divide it Right in two SCNR :) For everyone that doesn't know the text: I recommend listening to Tool's "Right in two". Although the text originally talks about war and strive, not programming. ;)
- jhgb 5y ago> I have this "theory" in the back of my head that trees are usually the wrong things to model thing in life but it's what come to us naturally. Have you by any chance read the relevant passages in SICP? It has some things to say about OOP ontologies.
- ferdowsi 5y agoCould you link this?
- Jtsummers 5y agohttps://mitpress.mit.edu/sites/default/files/sicp/full-text/book/book-Z-H-18.html#%_sec_2.5 https://mitpress.mit.edu/sites/default/files/sicp/full-text/... Possibly that section. It's not about OOP specifically, but about type hierarchies generally.
- Zababa 5y agoI don't think I did, I didn't finish the first chapter of SICP. I'm sure that I'm not the first one to come up with this though.
- oftenwrong 5y agoThere's a great old (2005) blog post on this topic: Clay Shirky - Ontology is Overrated: Categories, Links, and Tags https://web.archive.org/web/20191117162526/http://shirky.com/writings/ontology_overrated.html https://web.archive.org/web/20191117162526/http://shirky.com...
- state_less 5y agoFolks may enjoy some of these old posts too. https://en.m.wikipedia.org/wiki/Pyrrhonism https://en.m.wikipedia.org/wiki/Pyrrhonism For example, putting regions under a cold climates category, might not make sense to someone living near the pole where they would consider the same regions to be warm climates.
- Zababa 5y agoThanks, that was a great read. Tangentially related, but I wonder what's the impact of Windows having a really bad search. Maybe people are thus relying more on the folder hierarchies, and that influences how they think?
- firethief 5y agoYou might enjoy this essay from 1965, "A City is Not a Tree": https://www.patternlanguage.com/archive/cityisnotatree.html https://www.patternlanguage.com/archive/cityisnotatree.html
- prionassembly 5y agoOh man, I have a rabbit hole for you. https://en.wikipedia.org/wiki/Rhizome_(philosophy) https://en.wikipedia.org/wiki/Rhizome_(philosophy)
- steveklabnik 5y agoHere's a near-decade old talk from me on this exact topic: https://www.youtube.com/watch?v=YfKAScYkGlk https://www.youtube.com/watch?v=YfKAScYkGlk I haven't watched this in like... a long time, so maybe I'd think it's bad now.
- prionassembly 5y agoI recommend Manuel de Landa (stylizes his name to Delanda these days), particularly “Intensive Science and Virtual Philosophy” if your flavor is Anglo style analytical philosophy. The relevant Deleuze texts (A Thousand Plateaus) can be infuriating if you’re not open to this whole other style of thinking, but Deleuze is no postmodern, he’s a realist and a materialist and sort of a science worshipper, albeit from an angle that would make Neil deGrasse Tyson start bleeding from his nose until he passed out, if he ever grokked it. Start with Delanda, probably. [googling a little, this isn’t great but isn’t bad for something readily accessible: http://dar.aucegypt.edu/bitstream/handle/10526/3534/DeLanda%27s%20ontology.pdf?sequence=1 http://dar.aucegypt.edu/bitstream/handle/10526/3534/DeLanda%... ]
- steveklabnik 5y agoHeck yeah, in full agreement with all of that.