leave a note____
_newest entry___
__entry index___
___diaryland___

2012-10-01 - 7:10 a.m.

fuck the diamond problem. correct OO is based on inheritance. correct OO is almost never done because it was designed to approach the truly large projects, of which there may only be a handful currently existing. to do it right, we are supposed to correctly identify the responsibilities of the objects and then find meaningful, simple ways of categorising the objects implementing these responsibilities. then when we know a group of objects are specialisations of one type of object, they can inherit the functionality they all share anyway.

so.. diamond problem. two classes in correct OO never share the same responsibility. by definition, if they do then they inherit from their parent, seeing as they share a feature, which groups them together as children of the most basic form of that shared responsibility. so, since the same method conceptually does not exist in two classes, the diamond problem can only arise when two conceptually different methods share the same name. the problem then is not the "diamond problem", but a naming error.

multiple inheritance is logical when a single object falls into at least two categories making it simple for its implementation of at least two responsibilities to come from the at least two parents which define the at least two categories.

having nine parents would be just fine, the implication being that in the particular system being addressed, there are at least nine categories of similar objects and that responsibilities from each of those nine categories must be implemented in the same object. what other choice would one have? composition would fuck you in the ass because changing a base class method would require changing the child implementation accordingly. in a system as vast as the one which would be needed to require this much complexity, the nightmare from rebasing all the children would far exceed the nightmare of understanding the relationship the most complicated object has with its nine parents. hint, the relationship with nine parents should not be hard to understand. I shoot arrows well because my great great grandfather was a great hunter and passed this skill down through the generations. my blond hair comes from my mother and it is thick because hers is. I am tall because my great great great grandmother on my father's side was the tallest woman on the planet, etc etc etc. where is the confusion? oh wait, diamond problem alert! my mother had blue eyes and my father had brown eyes!! what the fuck does me.EyeColour() mean?? OH NOOOOEEESSSS! duh it means that my parents both inherited their eyes from a common ancestor and when we look in the definition of the common ancestor, we see "ah! at conception, randomly take genes from both parents to determine eye colour". woooo that was hard. Oh wait, you mean you DEFINED _and_ implemented an EyeColor() function in your mother AND father class, and further you coded it as Father::EyeColor(){return Brown;} and Mother::EyeColor(){return Blue;}?? oh, I get it, that means C++ IS FUCKED UP BECAUSE IT SUPPORTS MULTIPLE INHERITANCE... OHHHHH c# _is_ much better. bitches.

previous - next