From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-10-10T05:12:28+09:00 Subject: Polymorphism, Isomorphism Consider this a bit of public pondering... Polymorphism is considered a central idea in Object Oriented Programming. In typed languages like C++, polymorphism can only happen within a class hierarchy - there must be some kind of ISA relationship. In dynamic languages like Ruby no ISA relationship is needed - if two different classes respond to the same methods they can (often, but not always of course due to things like return values and semantics) be used in the same places. I'm wondering if this relation might actually be called Isomorphism - two classes with the ability to respond to the same set of methods but having no relationship to each other. (a 1 to 1 mapping of methods) If we look at a class as a set of methods (actually, maybe a module could be called a set of methods) then perhaps we could talk about whether another class _contains_ the same set of methods (subset and proper subset relationships could be defined). I guess what I'm leading up to would be something like being able to do: ClassA.isomorphic?(ClassB) #returns true if there is a 1:1 correspondence #between methods in ClassA and ClassB ClassA.containsMethods?(ClassB) #returns true if ClassA defines all of the # same methods that ClassB has defined (but # ClassA could define methods not defined in # ClassB The same operations would be applicable to objects which are members of these classes. Does the term Isomorphism work here? It seems that it might provide us with a distinction from Polymorphism (which people coming from a C++/Java world see as being distinctly related to inheritance). Also, what about this idea of set operations on Classes (where we look at classes and modules as sets of methods)? Would it buy us anything? ....just thinking 'out loud'. Phil