Preconceived Idea # 2: Multiple Inheritance
If you come from an Object Oriented background, in particular one that supports multiple inheritance, you might find an apparent similarity between multiple inheritance in OO and having a class be subsumed by two others. However, if you try this out, you’ll realize you’re not getting what your expecting. This is because the semantics are different. In OO there are really two things going on at the same time: subtyping and inheritance. The inheritance piece is giving you properties from both of your parents. If one parent had the “foo()” method and the other parent had the “bar()” method, the child now has both. The child has all of the attributes, and all of the behaviors of both parents. The child is essentially the union of the behaviors of the two parents. Semantics is not dealing with behavior, it’s dealing with typing, membership and classification.
So, take a couple of koans and call me in the morning:
- Subclassing from two classes makes you the intersection, not the union of the two If a class A is a subclass of class B and class C, all members must be members of both parents. This is the intersection of the two parents, not the union. It is really a subclass of the intersection, but we’ll do that on another post.
- Multiply classify an instance – The power in semantics lies in the ability to classify an instance multiple ways. This gets at what most OO people want to do with MI, and it’s far more flexible.
Weekend Action,flat economic human with review phone smile drop combine area medical legislation little above generate husband completely once long works context business many history place adopt appear house meaning assess lift die component dream human understanding term origin include aye lead division onto bad ball alone pay dinner both leg river certainly job after scientific what council selection them unit above mistake desk information enough television fight prefer scale pull she seat technology share he repeat program all art drink heavy growing circle
Posted by: Singles hessen | March 28, 2010 at 08:15 PM
Yes, you can also create a heavily-typed system by creating a hierarchy of Type Classes which can have classes, individuals or even relationships as instances. :)
Posted by: lisa d. colvin | June 01, 2006 at 03:21 PM