Lambda the Ultimate

inactiveTopic Interface based programming
started 2/7/2001; 12:30:09 PM - last post 2/8/2001; 1:47:05 PM
Ehud Lamm - Interface based programming  blueArrow
2/7/2001; 12:30:09 PM (reads: 1023, responses: 4)
Interface based programming
A former student of mine sent me this link saying it helped him understand some of the things we teach in our software enigneering course. Thought I'd share it with LtU readers.

Though OOP biased, and Microsoft centric, it seems to give some useful examples. Long as you remember that this is only one point of view, it might be helpful.

Still it is always worthwhile to iterate: interfaces are not an OOP concept!
Posted to Software-Eng by Ehud Lamm on 2/7/01; 12:31:07 PM

Chris Rathman - Re: Interface based programming  blueArrow
2/7/2001; 5:47:25 PM (reads: 946, responses: 0)
Interfaces may not be a strictly OOP concept, but don't OOP languages do them best? :-)

Funny thing about OO languages, though, is that the concepts of code inheritance, typing, and interfaces kind of runs together. Depending on which language you look at, these things are handled differently. Eiffel and C++ use the same multiple inheritance scheme to implement all three. Sather seperates the code inheritance from the typing & interfaces which are tied together. Java and C# have split off interfaces and leave typing and code inheritance tied together.

Ehud Lamm - Re: Interface based programming  blueArrow
2/8/2001; 12:04:25 AM (reads: 931, responses: 0)
don't OOP languages do them best? :-)

I am not sure about that smiley... No they don't do a very good job at all.

OOP provides one narrow view of interfaces, which has its uses and has proven itself useful in practice. However, it is far from being the only meaning of the term, and OO interfaces by themselves (with no guiding rules to keep you from shooting yourself in the head) can cause a lot of problems. Deep inheritance hierarchies seem to produce hard to maintain code (though the literature is inconclusive), something that is not obviously true for 'true' interfaces (i.e, layering). Other issues we discussed here also point to problematic areas: co/contra-variance;multiple inheritance (and mixins etc.); substitutionality is not guaranteed etc.

Worse: even if you overcome all these (which you won't), OO brings dynamic binding (even though some things can be done staticaly) which means pointers, memory mangement issues etc. This is true even when none onf this is required as far as interfaces are concerned (i.e., interfaces don't imply dynamic binding).

Another issue, related to PL research, is expressiveness. Consider the interface provided by a function in ML/Haskell giving you a polymorphic type signature, which uses high order functions, and is inferred from the code. Now copy this to OO. Doable, but far from easy or fun.

These are just some key points, I have more... OOP has its place, esp. as regards implementation reuse. As far as interfaces are concerned it is quite problematic, though still useful in practice.

andrew cooke - Re: Interface based programming  blueArrow
2/8/2001; 12:44:34 AM (reads: 950, responses: 1)
ML has a very impressive way of defining parameterized interfaces (IIRC you can parameterize them by a parameterized interface ;-). Haskell type classes are also interfaces (albeit not very well used in the Haskell Prolog, IMHO...).

Actually, I have some notes about interfaces in ML (SML from a while back) - they cover the nitty gritty details of exposing types, but do give a flavour of what is possible.

Ehud Lamm - Re: Interface based programming  blueArrow
2/8/2001; 1:47:05 PM (reads: 1005, responses: 0)
The ML approach is definitely worth a look for anyone interested in this topic. I found the Harper book useful.