Lambda the Ultimate

inactiveTopic Interfaces : a special construct of OO-Languages like Java/C# or only a crook?
started 11/6/2003; 12:19:27 PM - last post 11/7/2003; 12:13:17 AM
Karl Reitschuster - Interfaces : a special construct of OO-Languages like Java/C# or only a crook?  blueArrow
11/6/2003; 12:19:27 PM (reads: 223, responses: 5)
Hi, i am very used with oracle databases and PL/SQL. Due to objectoriented experiences in early 90tees with C++ i was really tensed about the new OO Features in PL/SQL with Oracle 9i. Somebody told me that PL/SQL lacks in having no interface-inheritance, but C#/Java have it. After a while i understood that interfaces are a 'could be- relation ship' ( instead of multiple inheritance ) and very important to handle different objecttypes in the same manner. So they are important for building flexible Components.

But i asked myself if interfaces would be necesseary for a native pure OO-Language which binds the method-call totally dynamicly. For example Smalltalk. So interfaces help to be more flexible in a generic way for 'typed object languages' like C++, Java, C# What do you think about this?

Orca

Daniel Yokomiso - Re: Interfaces : a special construct of OO-Languages like Java/C# or only a crook?  blueArrow
11/6/2003; 1:24:20 PM (reads: 202, responses: 0)
AFAICT interfaces are just sets of messages an object understands. In languages where you must associate messages with a type (i.e. you can't write "the type of an object that has 'size : Nat' and 'is-empty : Bool'") you need an explicit interface construct. In Smalltalk we could have:

myMethod: anObject with: somethingElse
  |interface|
  interface := #(#at:put:, #size) asSet.
  ^ (anObject understandsAll: interface)
         ifTrue: [anObject at: anObject size put: somethingElse]
         ifFalse: [self raiseTypeError: interface for: anObject].
Or something like that. Ocaml is statically typed with dynamic method binding and doesn't need explicit interfaces: every object type is just a set of messages.

Ehud Lamm - Re: Interfaces : a special construct of OO-Languages like Java/C# or only a crook?  blueArrow
11/6/2003; 1:29:55 PM (reads: 198, responses: 0)
But i asked myself if interfaces would be necesseary for a native pure OO-Language which binds the method-call totally dynamicly

You are right in that statically checked OOPL (i.e., compiled languages like Java, C++, Ada etc.) use abstract classes to ensure that a derived claases support a specific signature. Interfaces are essentially an extnesion of this concept, helpful in those cases where were want to support multiple interface inheritance without having to deal with the issues multiple implementation inheritance brings to the table.

Obviously, if you don't check statically method calls you don't need to exlicitly declare interfaces, and at worst raise an exception or invoke a 'don't understand' method.

Personally, I think interfaces are much more fundamental than classes, inheritance, binding times etc. so I wouldn't vote for the proposition you are trying to make. Sure, dynamic OO languages don't really need an interface construct, but I would prefer a language with a clear construct for interfaces than a language without one.

Part of the appeal of OOP is subclass polymorphism which alows you to write "interface oriented code" (coding upto a required interface). This is, of course, possible even if interfaces are not explicitly declared, but since this is such a fundamental programming style, I prefer clear language support and er.. encouragement

Isaac Gouy - Re: Interfaces : a special construct of OO-Languages like Java/C# or only a crook?  blueArrow
11/6/2003; 2:12:30 PM (reads: 188, responses: 0)
In Smalltalk we could have

SmallInterfaces - interfaces for Smalltalk (previously on LtU)

Karl Reitschuster - Re: Interfaces : a special construct of OO-Languages like Java/C# or only a crook?  blueArrow
11/7/2003; 12:13:17 AM (reads: 173, responses: 0)
Hi, thanks for reply, i recognize to have my focus more on interfaces then before; blessed, Orca