Multiple Inheritance

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
27 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Inheritance

Nowak, Helge

Wouldn’t be Spoon and Fork be subclasses of Spork?

 

Von: Paul Baumann [mailto:[hidden email]]
Gesendet: Montag, 11. Juni 2012 17:26
An: Conrad Taylor
Cc: Nowak, Helge; Niall Ross; andre; VWNC list
Betreff: RE: [vwnc] Multiple Inheritance

 

My recollection is...

 

It was about how to classify objects (kitchen utensils in this case). She asked the class to name all the utensils they could think of. Each was written on an index card. http://en.wikipedia.org/wiki/List_of_food_preparation_utensils. She asked for ideas about how they might be classified (by material, use, location of use, stage of use, context of use, etc.). There was discussion and disagreement of course. Attributes of each were added to each card. The attributes helped some (by defining a classification epistemology). Though classification rules were now defined, utensils still failed to be conform in a way that supports single inheritance. Would a "spork" be  a kind of fork or spoon? With SI, you can only pick one. Should a new kind of abstract utensil class be created to accommodate the spork? Still then, what is the superclass of a spork? Neither would be ideal and behavior for the other class would have to be copied to the Spork.

 

This is when she introduced the notion of multiple inheritance and that Smalltalk doesn't have it (C++ started to seem cool for a moment). But what could be done for Smalltalk though? The answer was to define a hierarchy of responsibilities (each with attributes and behavior). A Spork would then be defined as a combination of responsibilities/abstractions that were bridged together and yet still behaved as a class for which instances could be created. Spork was neither a subclass of fork nor spoon but shared the same superclass. The hierarchy of utensil classes could become shallower and more manageable as two separate hierarchies. Separation into two hierarchies of responsibility (that are bridged together) was more maintainable than a pure MI approach. All that Smalltalk needed was a simple framework to allow classes to be defined as a mixture of the behavior of other classes.

 

A mixin framework can be described as support for the automatic maintenance of mixed-in responsibilities to reduce the redundancy that normally evolves from SI. A mixin framework is a tool to help a developer increase code reuse and reduce code maintenance costs.

 

I had set about to implement a framework to make this easy to manage. At first I called it a Multiple Inheritance framework. Then later renamed code to use either "mixin" or "pidgin" once I saw that those terms seemed to have already been established for use in other languages. The terms were not familiar to many though. Delegation of behavior was the easy part to implement; the trickier issues were around attribute implementation and preservation of "self". I used template compiled methods that were copied with modification directly into the method dictionary. In one implementation, "self" was preserved through #== checks on the results from forwarded messages. The sequence of inherited behaviors defined behavior inheritance priority. If Spork was defined with responsibility of first Spoon and then Fork then a common method like #printOn: would by default to that of Spoon. Spork could of course define #printOn: a more appropriate way while still being able to explicitly call the behavior inherited from Spoon or Fork. I'd experimented with other implementation variations too (things like associated attributes and automatic local copies of behavior). An implementation I settled on had an array of instances of inherited responsibilities for which methods were configured to access the correct index position. It was the responsibility of the framework to automatically keep all inherited behavior and references in sync as code evolved. It worked well, but had tricks so that code management tools like ENVY would not get confused. Another tricky area was in related to inheritance from classes (like Date and Float) that aren't created (and initialized) like most other objects.

 

The idea at the time was to encourage Smalltalk vendors to adopt an implementation as standard. That started to happen but those that developed interest always wanted to start their own implementation from scratch and just did the #doesNotUnderstand: tricks alone and later gave up when preservation of "self" became recognized as a challenge. That was one of my first experiences with attempting to help evolve the Smalltalk language. The cultural challenges never got much better. For better and worse, Smalltalk is a closed language that evolves or dies by the choices of a few vendors and from the inspiration of a few employed by those vendors. Lacking a market that could develop a financial incentive, the only motivation that exists for frameworks like this is personal pride of accomplishment. That is why every Smalltalker "re-invents the wheel" and also why really good frameworks rarely get shared or used. Smalltalk development is a culture of one.

 

GS/S and now VisualWorks have the ability to associate state directly to instances (without the traditional trick of weak reference lookup tables). Features like this can make for more efficient mixin frameworks that can preserve "self" easier than the ones I'd implemented. Hopefully someone will leverage this new feature to establish a good mixin framework that we will all use.

 

Paul Baumann

 

 

 

From: Conrad Taylor [hidden email]
Sent: Monday, June 11, 2012 03:00
To: Paul Baumann
Cc: Nowak, Helge; Niall Ross; andre; VWNC list
Subject: Re: [vwnc] Multiple Inheritance

 

On Fri, Jun 8, 2012 at 9:31 AM, Paul Baumann <[hidden email]> wrote:

Rebecca Wirfs-Brock had given an on-site Smalltalk training session back around 1994 in which she gave a good example of where single inheritance breaks down. Her example involved classifying kitchen utensils. Single inheritance quickly broke down and duplication was one escape. MI would have solved the problem if it existed for Smalltalk.

 

Paul, do you have any more information about the example that Rebecca Wirfs-Brock had given?

 

MI frameworks are an ideal that maximizes code reuse. In my experience, I've seen people make too many mistakes with SI to think they would possibly do a good job with MI. Even more though, most programmers are application developers that have absolutely no reservations about copying behavior. Code reuse happens when code is refactored, and most development managers of that era exaggerated the risks of refactoring "working" code to make it more maintainable.

Sometime after Rebecca's course I developed a mixin framework for VAST (which was called ENVY/400 at that time). The framework worked excellent but for ultimate performance it relied on a few tricks that few people would attempt. Inherited behavior (that was not explicit) fell to #doesNotUnderstand: (as most mixin frameworks do) but the framework would then insert a special pattern method into the method dictionary to optimize for subsequent sends. The tricky part about doing this is that code management tools handle these special methods correctly. The mixin framework worked well and I made it public domain for others to use. As simple as it was, there was a learning curve for new users. Eventually I stopped using it myself due to the overwhelming reistance to refactoring at that time.

Other people created MI and mixin frameworks for Smalltalk around that time too. I suspect they had the same experience as I had. Perhaps it would be more accepted today now that refactoring is acceptable. Even today though, people just copy code and do not care about future maintainability. SI is good enough for most development and people don't tend to notice when it fails because by that time they want to rewrite all the code anyway.

Paul Baumann






-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Nowak, Helge
Sent: Friday, June 08, 2012 10:22
To: Niall Ross; andre
Cc: VWNC list
Subject: Re: [vwnc] Multiple Inheritance

There used to be an MI framework for VisualWorks available from Applied Reasoning till the late 90-ies. It had been developed by Bill Burdick who - according to LinkedIn - runs today his own company "Mobile Reasoning". Maybe you want to contact him for his opinion and solution.

Interesting is also to look at why Java and C# don't have multiple inheritance. See a discussion here: http://stackoverflow.com/questions/995255/why-is-multiple-inheritance-not-allowed-in-java-or-c
Or, more academic, this paper: http://www.cs.wright.edu/~tkprasad/papers/mi.pdf

HTH
Helge

-----Ursprüngliche Nachricht-----
Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Niall Ross
Gesendet: Freitag, 8. Juni 2012 15:23
An: andre
Cc: VWNC list
Betreff: Re: [vwnc] Multiple Inheritance

Dear Andre,
   the only time I've ever wanted multiple inheritance, or at least mixins, is when implementing a meta-data framework.  Some state is required, so stateless traits don't cover this case.

There was a discussion of this case at ESUG 2005 in Brussels, recorded on page 55 of the report:

http://www.esug.org/data/ReportsFromNiallRoss/nfrESUG2005report.pdf

So perhaps I don't quite agree with those who say it is never needed, but my experience is that it is rarely needed.  Thus I'd agree on keeping it out of the base, though happy to see the framework Georg suggested, or similar, available to load as a prereq of specific applications.

I'd guess another legitimate use would be when porting a system where MI has been used to Smalltalk (I've never had occasion to do that myself).

            Yours faithfully
                  Niall Ross

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



 

--

 

Think different and code well,

 

-Conrad

 

 

 


This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Inheritance

skrish
In reply to this post by Paul Baumann
Obliged if this can be elaborated on:

"GS/S and now VisualWorks have the ability to associate state directly to instances (without the traditional trick of weak reference lookup tables)"

On Mon, Jun 11, 2012 at 8:56 PM, Paul Baumann <[hidden email]> wrote:

My recollection is...

 

It was about how to classify objects (kitchen utensils in this case). She asked the class to name all the utensils they could think of. Each was written on an index card. http://en.wikipedia.org/wiki/List_of_food_preparation_utensils. She asked for ideas about how they might be classified (by material, use, location of use, stage of use, context of use, etc.). There was discussion and disagreement of course. Attributes of each were added to each card. The attributes helped some (by defining a classification epistemology). Though classification rules were now defined, utensils still failed to be conform in a way that supports single inheritance. Would a "spork" be  a kind of fork or spoon? With SI, you can only pick one. Should a new kind of abstract utensil class be created to accommodate the spork? Still then, what is the superclass of a spork? Neither would be ideal and behavior for the other class would have to be copied to the Spork.

 

This is when she introduced the notion of multiple inheritance and that Smalltalk doesn't have it (C++ started to seem cool for a moment). But what could be done for Smalltalk though? The answer was to define a hierarchy of responsibilities (each with attributes and behavior). A Spork would then be defined as a combination of responsibilities/abstractions that were bridged together and yet still behaved as a class for which instances could be created. Spork was neither a subclass of fork nor spoon but shared the same superclass. The hierarchy of utensil classes could become shallower and more manageable as two separate hierarchies. Separation into two hierarchies of responsibility (that are bridged together) was more maintainable than a pure MI approach. All that Smalltalk needed was a simple framework to allow classes to be defined as a mixture of the behavior of other classes.

 

A mixin framework can be described as support for the automatic maintenance of mixed-in responsibilities to reduce the redundancy that normally evolves from SI. A mixin framework is a tool to help a developer increase code reuse and reduce code maintenance costs.

 

I had set about to implement a framework to make this easy to manage. At first I called it a Multiple Inheritance framework. Then later renamed code to use either "mixin" or "pidgin" once I saw that those terms seemed to have already been established for use in other languages. The terms were not familiar to many though. Delegation of behavior was the easy part to implement; the trickier issues were around attribute implementation and preservation of "self". I used template compiled methods that were copied with modification directly into the method dictionary. In one implementation, "self" was preserved through #== checks on the results from forwarded messages. The sequence of inherited behaviors defined behavior inheritance priority. If Spork was defined with responsibility of first Spoon and then Fork then a common method like #printOn: would by default to that of Spoon. Spork could of course define #printOn: a more appropriate way while still being able to explicitly call the behavior inherited from Spoon or Fork. I'd experimented with other implementation variations too (things like associated attributes and automatic local copies of behavior). An implementation I settled on had an array of instances of inherited responsibilities for which methods were configured to access the correct index position. It was the responsibility of the framework to automatically keep all inherited behavior and references in sync as code evolved. It worked well, but had tricks so that code management tools like ENVY would not get confused. Another tricky area was in related to inheritance from classes (like Date and Float) that aren't created (and initialized) like most other objects.

 

The idea at the time was to encourage Smalltalk vendors to adopt an implementation as standard. That started to happen but those that developed interest always wanted to start their own implementation from scratch and just did the #doesNotUnderstand: tricks alone and later gave up when preservation of "self" became recognized as a challenge. That was one of my first experiences with attempting to help evolve the Smalltalk language. The cultural challenges never got much better. For better and worse, Smalltalk is a closed language that evolves or dies by the choices of a few vendors and from the inspiration of a few employed by those vendors. Lacking a market that could develop a financial incentive, the only motivation that exists for frameworks like this is personal pride of accomplishment. That is why every Smalltalker "re-invents the wheel" and also why really good frameworks rarely get shared or used. Smalltalk development is a culture of one.

 

GS/S and now VisualWorks have the ability to associate state directly to instances (without the traditional trick of weak reference lookup tables). Features like this can make for more efficient mixin frameworks that can preserve "self" easier than the ones I'd implemented. Hopefully someone will leverage this new feature to establish a good mixin framework that we will all use.

 

Paul Baumann

 

 

 

From: Conrad Taylor [mailto:[hidden email]]
Sent: Monday, June 11, 2012 03:00
To: Paul Baumann
Cc: Nowak, Helge; Niall Ross; andre; VWNC list


Subject: Re: [vwnc] Multiple Inheritance

 

On Fri, Jun 8, 2012 at 9:31 AM, Paul Baumann <[hidden email]> wrote:

Rebecca Wirfs-Brock had given an on-site Smalltalk training session back around 1994 in which she gave a good example of where single inheritance breaks down. Her example involved classifying kitchen utensils. Single inheritance quickly broke down and duplication was one escape. MI would have solved the problem if it existed for Smalltalk.

 

Paul, do you have any more information about the example that Rebecca Wirfs-Brock had given?

 

MI frameworks are an ideal that maximizes code reuse. In my experience, I've seen people make too many mistakes with SI to think they would possibly do a good job with MI. Even more though, most programmers are application developers that have absolutely no reservations about copying behavior. Code reuse happens when code is refactored, and most development managers of that era exaggerated the risks of refactoring "working" code to make it more maintainable.

Sometime after Rebecca's course I developed a mixin framework for VAST (which was called ENVY/400 at that time). The framework worked excellent but for ultimate performance it relied on a few tricks that few people would attempt. Inherited behavior (that was not explicit) fell to #doesNotUnderstand: (as most mixin frameworks do) but the framework would then insert a special pattern method into the method dictionary to optimize for subsequent sends. The tricky part about doing this is that code management tools handle these special methods correctly. The mixin framework worked well and I made it public domain for others to use. As simple as it was, there was a learning curve for new users. Eventually I stopped using it myself due to the overwhelming reistance to refactoring at that time.

Other people created MI and mixin frameworks for Smalltalk around that time too. I suspect they had the same experience as I had. Perhaps it would be more accepted today now that refactoring is acceptable. Even today though, people just copy code and do not care about future maintainability. SI is good enough for most development and people don't tend to notice when it fails because by that time they want to rewrite all the code anyway.

Paul Baumann






-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Nowak, Helge
Sent: Friday, June 08, 2012 10:22
To: Niall Ross; andre
Cc: VWNC list
Subject: Re: [vwnc] Multiple Inheritance

There used to be an MI framework for VisualWorks available from Applied Reasoning till the late 90-ies. It had been developed by Bill Burdick who - according to LinkedIn - runs today his own company "Mobile Reasoning". Maybe you want to contact him for his opinion and solution.

Interesting is also to look at why Java and C# don't have multiple inheritance. See a discussion here: http://stackoverflow.com/questions/995255/why-is-multiple-inheritance-not-allowed-in-java-or-c
Or, more academic, this paper: http://www.cs.wright.edu/~tkprasad/papers/mi.pdf

HTH
Helge

-----Ursprüngliche Nachricht-----
Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Niall Ross
Gesendet: Freitag, 8. Juni 2012 15:23
An: andre
Cc: VWNC list
Betreff: Re: [vwnc] Multiple Inheritance

Dear Andre,
   the only time I've ever wanted multiple inheritance, or at least mixins, is when implementing a meta-data framework.  Some state is required, so stateless traits don't cover this case.

There was a discussion of this case at ESUG 2005 in Brussels, recorded on page 55 of the report:

http://www.esug.org/data/ReportsFromNiallRoss/nfrESUG2005report.pdf

So perhaps I don't quite agree with those who say it is never needed, but my experience is that it is rarely needed.  Thus I'd agree on keeping it out of the base, though happy to see the framework Georg suggested, or similar, available to load as a prereq of specific applications.

I'd guess another legitimate use would be when porting a system where MI has been used to Smalltalk (I've never had occasion to do that myself).

            Yours faithfully
                  Niall Ross

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



 

--

 

Think different and code well,

 

-Conrad

 

 



This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Inheritance

Paul Baumann
In reply to this post by Nowak, Helge

Sure, if you want to disable (or ignore) Spoon-specific behavior in Fork and and Fork-specific behavior in Spoon. Some senders of #shouldNotImplement could be examples of that kind of inheritance. Lots of ways to do it. Most subclasses try to add rather than subtract, but exceptions are acceptable. Likewise, most would prefer "c = a + b" over "a = c - b" because the nature of a, b, and c are expressed in a more elemental and intuitive way. I posit that subtraction and division in an equation can suggest adjustment for a classification error. An inheritance structure that subtracts can have valid behavior but to me it suggests classification problems.

 

Rebecca's utensils example was good for showing challenges but I can't really think of what instance variables and methods I'd want to define on any utensil. What scenario would I want to create an instance of a Spoon and know how it differs from a Fork? It would have to be some form of environment modeling where a spoon instance has position, mass, dimensions, velocity, material, temperature, etc. and this spoon differs from standard in that the handle is bent.... If the instance could accommodate knowledge of a bent handle then what about other modifications like discoloration, cuts, temperature differences, electron flow, etc. At some point it is realized that "the spoon does not exist" meaning that the spoon is a configuration of materials that make it appear as a classification people simplify to their personal notion of a spoon. A general definition of a spoon is of little value in this modeling environment as the understanding of a spoon is personal. To one person, the handle of a spoon will open a paint can as well as a the handle of a fork. To another person, a tea spoon is a better choice for use for a specific purpose. "Spoon" is a common classification of an object for the purpose of communication between actors in that environment. The spoon does not exist to the modeling environment but it exists according to the understanding of each actor in the environment. The understanding of the spoon is subjective but to objective classification rules that are subjectively acknowledged. The value of a "spoon" is a reflection of the personal understanding of how an actor may use it. An atom is a relatively consistent arrangement of electrons that are subject to expansion (sorry that differs from the common understanding of the internal structure of the atom). A "spoon" to the physical world is an arrangement of atoms. The first level of classification of that "spoon" is which atoms are considered to be part of that arrangement. One can classify the relationships between Spoon, Fork, and Spork any many ways and still be successful (defined by favorable interaction). The classification is for ease communication. Classifications evolve as sporks and platypus are recognized. The Natural Law is that classification choices are dynamic and personal.

 

In other words, sure, one can argue a Fork a kind of Spork just as well as another could argue that is is not. It would be an argument over subjective minutiae that communication more than the value that the spork can bring to an actor.

 

Paul Baumann

 

 

 

From: Nowak, Helge [mailto:[hidden email]]
Sent: Monday, June 11, 2012 11:32
To: Paul Baumann; Conrad Taylor
Cc: Niall Ross; andre; VWNC list
Subject: AW: [vwnc] Multiple Inheritance

 

Wouldn’t be Spoon and Fork be subclasses of Spork?



This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Inheritance

Paul Baumann
In reply to this post by skrish

GS/S has always had #tagAt: and #tagAt:put: but it was limited to two attribute slots per object. This can be useful for example for an object to know what indexes it is involved in without having to add an 'indexes' instance variable to every class (and instance). Newer versions of GS/S basically extend this idea to give an infinite number of named tags (dynamic instance variables) that can be used by each object.  The instance variables are closely associated with each object just as a normal instance variable (with respect to garbage collection and such). These dynamic variables do not need to have a slot allocated in memory for every instance. They don't need to be visible in object inspectors either.

 

Look at #myDependents in VW for an example of dynamic associated attributes. Object>>myDependents uses a lookup table to find the dependents associated with an object. Subclasses that commonly have dependents that override #myDependents to use an instance variable that they define. In other words, all objects have #myDependents to varying levels of need and efficiency.

 

GemBuilder for Smalltalk (GBS) allows transparent access to automatically maintained state in either the VW image or GS gem. In order to do this it needs to be able to associate a GS delegate object to each real VW object and then coordinate changes through caches. Those caches need to have weak references to the object that the delegate is affiliated with so that the VW image can release objects (and delegates) no longer needed. The caches are identity hashed collections that are subject to identity hash limitations (which is a serious performance problem). When you can associate the GS delegate to objects without using the identity cache then you can greatly improve performance (actually you need to associate an oop cache association that knows the delegate, but I won't get into those details). The point is, this is another use of dynamic instance variables.

 

Shouldn't such a cool trick of dynamic instance variables have general availability? If it did then GBS and other frameworks wouldn't have to implement their own lookup caches and later deal with the details of weak array finalization.

 

I was pleased to hear that dynamic instance variables are coming to newer versions of VW. It open a whole new world of possibilities and performance for those that have had to use identity-based associative indexes. I've only heard the announcement (at the last STIC conference) that VW will have them, I don't know what Cincom is calling them or what releases they are part of. If done right, it will be a big opportunity for frameworks that wish to extend the attributes of each object (for the needs of the framework) without modifying the class definition.

 

Paul Baumann

 

 

 

From: Sudhakar Krishnamachari [mailto:[hidden email]]
Sent: Monday, June 11, 2012 12:19
To: Paul Baumann
Cc: Conrad Taylor; VWNC list; andre
Subject: Re: [vwnc] Multiple Inheritance

 

Obliged if this can be elaborated on:

 

"GS/S and now VisualWorks have the ability to associate state directly to instances (without the traditional trick of weak reference lookup tables)"

On Mon, Jun 11, 2012 at 8:56 PM, Paul Baumann <[hidden email]> wrote:



This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Inheritance

Cesar Rabak
In reply to this post by Nowak, Helge
Em 11/6/2012 12:31, Nowak, Helge escreveu:
> Wouldn’t be Spoon and Fork be subclasses of Spork?

This is an interesting discussion! WRT your specific question, present
OOA would respond with a unconditional /no/, the reason being the same
we do not create an hierarchy of of geometric classes having Ellipsoid
as superclass of Circle¹.


--
Cesar Rabak
GNU/Linux User 52247.
Get counted: http://counter.li.org/

[1] I'm being finicky here, as I chose surfaces, which make more sense
in [graphics] programming.
_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Inheritance

Nowak, Helge
In reply to this post by Paul Baumann

Usually you do not have black/white classifications but all shades in between: utensils with spoonishness and forkishness. Whether or not it is used as (materializes?) a spoon or fork depends indeed on the situation/context.

 

Von: Paul Baumann [mailto:[hidden email]]
Gesendet: Montag, 11. Juni 2012 19:09
An: Nowak, Helge; Conrad Taylor
Cc: Niall Ross; andre; VWNC list
Betreff: RE: [vwnc] Multiple Inheritance

 

Sure, if you want to disable (or ignore) Spoon-specific behavior in Fork and and Fork-specific behavior in Spoon. Some senders of #shouldNotImplement could be examples of that kind of inheritance. Lots of ways to do it. Most subclasses try to add rather than subtract, but exceptions are acceptable. Likewise, most would prefer "c = a + b" over "a = c - b" because the nature of a, b, and c are expressed in a more elemental and intuitive way. I posit that subtraction and division in an equation can suggest adjustment for a classification error. An inheritance structure that subtracts can have valid behavior but to me it suggests classification problems.

 

Rebecca's utensils example was good for showing challenges but I can't really think of what instance variables and methods I'd want to define on any utensil. What scenario would I want to create an instance of a Spoon and know how it differs from a Fork? It would have to be some form of environment modeling where a spoon instance has position, mass, dimensions, velocity, material, temperature, etc. and this spoon differs from standard in that the handle is bent.... If the instance could accommodate knowledge of a bent handle then what about other modifications like discoloration, cuts, temperature differences, electron flow, etc. At some point it is realized that "the spoon does not exist" meaning that the spoon is a configuration of materials that make it appear as a classification people simplify to their personal notion of a spoon. A general definition of a spoon is of little value in this modeling environment as the understanding of a spoon is personal. To one person, the handle of a spoon will open a paint can as well as a the handle of a fork. To another person, a tea spoon is a better choice for use for a specific purpose. "Spoon" is a common classification of an object for the purpose of communication between actors in that environment. The spoon does not exist to the modeling environment but it exists according to the understanding of each actor in the environment. The understanding of the spoon is subjective but to objective classification rules that are subjectively acknowledged. The value of a "spoon" is a reflection of the personal understanding of how an actor may use it. An atom is a relatively consistent arrangement of electrons that are subject to expansion (sorry that differs from the common understanding of the internal structure of the atom). A "spoon" to the physical world is an arrangement of atoms. The first level of classification of that "spoon" is which atoms are considered to be part of that arrangement. One can classify the relationships between Spoon, Fork, and Spork any many ways and still be successful (defined by favorable interaction). The classification is for ease communication. Classifications evolve as sporks and platypus are recognized. The Natural Law is that classification choices are dynamic and personal.

 

In other words, sure, one can argue a Fork a kind of Spork just as well as another could argue that is is not. It would be an argument over subjective minutiae that communication more than the value that the spork can bring to an actor.

 

Paul Baumann

 

 

 

From: Nowak, Helge [hidden email]
Sent: Monday, June 11, 2012 11:32
To: Paul Baumann; Conrad Taylor
Cc: Niall Ross; andre; VWNC list
Subject: AW: [vwnc] Multiple Inheritance

 

Wouldn’t be Spoon and Fork be subclasses of Spork?

 


This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of IntercontinentalExchange, Inc. (ICE), its subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: Multiple Inheritance

Conrad Taylor
In reply to this post by Björn Eiderbäck-2
On Thu, Jun 7, 2012 at 12:04 PM, Björn Eiderbäck <[hidden email]> wrote:
Sorry I managed to push the send button.
But I was about to recommend (but I have just started reading it):

Traits: Composable Units of Behaviour⋆ by Nathanael Scha ̈rli, Ste ́phane Ducasse, Oscar Nierstrasz, and Andrew P. Black

http://www.google.se/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0CFkQFjAA&url=http%3A%2F%2Fscg.unibe.ch%2Farchive%2Fpapers%2FScha03aTraits.pdf&ei=0PrQT936D6344QS645imDw&usg=AFQjCNFjNhr_DuVx5vlDWsryTj0TZYfaBA&sig2=RGwyCxnaCxbRVLtp7uDaoQ

They also refer to papers about multiple inheritance.

Best Regards
Björn


On Thu, Jun 7, 2012 at 8:58 PM, Björn Eiderbäck <[hidden email]> wrote:
I was a little bit curios about traits in Scala an read a bit in a Scala book. However I thought that it could be a better explanation of the concept. So I search a bit and found that there was some quite early papers on traits that used Smalltalk to describe and examplify it!
O
I just started reading


Björn, it would be great if all the Smalltalks supported a single implementation of Traits.  For example, Pharo supports an implementation of Traits out-of-the-box.  Also, one can find an implementation of Traits for VW here but I'm not sure of the state and whether or not it's compatible with recent releases of VW:


Next, it would be great if all Smalltalk environments enhanced the core language features in similar ways to make it easier to move code from one to another.  In short, there needs to be an executable Smalltalk language specification and better communication between the vendors/implementors.
 
On Thu, Jun 7, 2012 at 8:40 PM, Brad Selfridge <[hidden email]> wrote:
When I worked at Boeing,  in Wichita, KS, we had an application that ran the payroll system.  The problem was that the application was "one" program. It did everything cause it was the "payroll" process. Turns out the "one" program was over 250,000 lines of code and only the creator was able to understand and make changes to the program. The "one" program was immediately re-written once the creator retired. 

I have also seen a lot of Java developers load up a class with many different disparate functions and "scream" in your face stating that they were writing OO code because the language was Java.

I have been writing Smalltalk (mostly) and other OO programs for close to twenty years and I have rarely run into an instance where I wished that I could use MI.  I was always able to implement delegation and solve the problem.

It seems to me that the example you provided should be implemented in several classes that is wrapped in an manager class.  Not sure MI is the best solution in this instance.

Brad Selfridge


On 6/7/2012 1:07 PM, James Robertson wrote:
Imho, delegation is far easier to maintain.  For one thing, you don't need to "cover" all the inherited code you don't need

On Thursday, June 7, 2012, andre wrote:

Thanks for the pointers, Georg. Interesting read.

I see the points, but am inclined to disagree with such a general verdict against MI. There are legitimate uses for it, although it can certainly be abused to create a mess.

Code readability is, and Smalltalkers know that best, a question of the right tools. Plain source "files" are almost always hard to read, no matter which language.

One interesting thing I recently observed concerning the way my thoughts tend to go is, that the typical thought pattern when creating a new class in Smalltak is "of what existing class *is* this object a derivate or specialization?" It is an ontological model. In contrast, the typical thought in C++ is "what is this object supposed to be able to *do*?", which is a behavioral model.

Either model has its advantages and disadvantages. If for example, I have an object that is supposed to be able to

- Run a background thread
- Receive and process jobs from a queue
- Broadcast events to dependent objects
- Provide a server on a network that clients can connect to
- Receive and react to OS events
- Implement application specific behavior that builds on all the above

then using MI, all but the last point could be simply assembled from existing classes. In Smalltalk, I would need to add a lot of protocols and copy/paste/rewrite code from elsewhere.

Delegation is verbose and laborious and hard to maintain. Also if the individual delegates of an object need to share a great deal of common state, things are getting even more laborious.

Andre



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc




_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc




--

Think different and code well,

-Conrad



_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
12