By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 986 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

The 'Interface' Type - Unique to .NET?

P: n/a
In OOP literature we read frequently about "interface" - a term which is
apparently used to mean different things depending on context and possibly
language.

..NET however provides for the Interface type - as a specific and unique type
(amongst the class, struct, enum, etc types). There is no ambiguity about
its meaning; it's a very specific thing (a .NET type) independent of
context.

My question: I am wondering of other OOP languages like Smalltalk and Java
provide an interface type as well - or if 'interface' is a type unique to
..NET.

Thanks.
Mar 16 '06 #1
Share this Question
Share on Google+
18 Replies


P: n/a
Jordan,

Java also offers interface types, in a way very similar to .NET.
The concept of interface was first used in the language Objective C.

Regards - Octavio
"Jordan" <A@B.COM> escribió en el mensaje
news:Of*************@TK2MSFTNGP12.phx.gbl...
In OOP literature we read frequently about "interface" - a term which is
apparently used to mean different things depending on context and possibly
language.

.NET however provides for the Interface type - as a specific and unique
type (amongst the class, struct, enum, etc types). There is no ambiguity
about its meaning; it's a very specific thing (a .NET type) independent of
context.

My question: I am wondering of other OOP languages like Smalltalk and Java
provide an interface type as well - or if 'interface' is a type unique to
.NET.

Thanks.

Mar 16 '06 #2

P: n/a

Well, it allows for an /interface/ as in a class that can be an
interface with interface methods.

But there is (in Java) no 'interface' type or keyword.

MyClass implements MyInterface

Where MyInterface is just a class built to the rules of a java interface.

Octavio Hernandez wrote:
Jordan,

Java also offers interface types, in a way very similar to .NET.
The concept of interface was first used in the language Objective C.

Regards - Octavio
"Jordan" <A@B.COM> escribió en el mensaje
news:Of*************@TK2MSFTNGP12.phx.gbl...
In OOP literature we read frequently about "interface" - a term which is
apparently used to mean different things depending on context and possibly
language.

.NET however provides for the Interface type - as a specific and unique
type (amongst the class, struct, enum, etc types). There is no ambiguity
about its meaning; it's a very specific thing (a .NET type) independent of
context.

My question: I am wondering of other OOP languages like Smalltalk and Java
provide an interface type as well - or if 'interface' is a type unique to
.NET.

Thanks.


Mar 16 '06 #3

P: n/a
Thanks, John!

I've been out of the Java world for a while...

Regards - Octavio
"John Bailo" <ja*****@texeme.com> escribió en el mensaje
news:Z7********************@speakeasy.net...

Well, it allows for an /interface/ as in a class that can be an interface
with interface methods.

But there is (in Java) no 'interface' type or keyword.

MyClass implements MyInterface

Where MyInterface is just a class built to the rules of a java interface.

Octavio Hernandez wrote:
Jordan,

Java also offers interface types, in a way very similar to .NET.
The concept of interface was first used in the language Objective C.

Regards - Octavio
"Jordan" <A@B.COM> escribió en el mensaje
news:Of*************@TK2MSFTNGP12.phx.gbl...
In OOP literature we read frequently about "interface" - a term which is
apparently used to mean different things depending on context and
possibly language.

.NET however provides for the Interface type - as a specific and unique
type (amongst the class, struct, enum, etc types). There is no ambiguity
about its meaning; it's a very specific thing (a .NET type) independent
of context.

My question: I am wondering of other OOP languages like Smalltalk and
Java provide an interface type as well - or if 'interface' is a type
unique to .NET.

Thanks.



Mar 16 '06 #4

P: n/a
"Jordan"
In OOP literature we read frequently about "interface" - a term which is
apparently used to mean different things depending on context and possibly
language.

.NET however provides for the Interface type - as a specific and unique
type (amongst the class, struct, enum, etc types). There is no ambiguity
about its meaning; it's a very specific thing (a .NET type) independent of
context.

My question: I am wondering of other OOP languages like Smalltalk and Java
provide an interface type as well - or if 'interface' is a type unique to
.NET.

Thanks.


Delphi implements Interfaces exactly like C#. Humnnn, I wonder if Mr.
Hejlsberg had something to do with that.

Cheers

Padu
Mar 16 '06 #5

P: n/a
"Padu" <pa**@merlotti.com> a écrit dans le message de news:
Ya********************@iswest.net...

| Delphi implements Interfaces exactly like C#. Humnnn, I wonder if Mr.
| Hejlsberg had something to do with that.

Not true. Delphi interfaces for Win32 are based on the COM specification
where you have a base interface type, either IUnknown or IInterface which
has _AddRef; _Release and QueryInterface methods. They are reference counted
and any class that supports interfaces can derive from TInterfacedObject
which implements those three methods. Every object has an interface table
and the addresses for each interface differ from the address of the
implementing object.

In C#, interfaces are their own type with no base definition. They don't
have any relationship to COM, unless a GUID is declared for them.
Implementing objects and all other interfaces implemented by that object all
return the same address. .NET interfaces are not reference counted, instead
they are just alternative references to an object which can be garbage
collected.

It is only with .NET that Delphi interfaces changed to follow the .NET
model.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Mar 16 '06 #6

P: n/a
John,

In JAVA, there is an interface type and keyword.

http://java.sun.com/docs/books/tutor...erfaceDef.html

Best regards,

Renze de Waal.

On Thu, 16 Mar 2006 11:26:47 -0800, John Bailo <ja*****@texeme.com>
wrote:

Well, it allows for an /interface/ as in a class that can be an
interface with interface methods.

But there is (in Java) no 'interface' type or keyword.

MyClass implements MyInterface

Where MyInterface is just a class built to the rules of a java interface.

Mar 16 '06 #7

P: n/a

What does 'interface' do for me that implements with an non-interface
doesn't?
Renze de Waal wrote:
John,

In JAVA, there is an interface type and keyword.

http://java.sun.com/docs/books/tutor...erfaceDef.html

Best regards,

Renze de Waal.

On Thu, 16 Mar 2006 11:26:47 -0800, John Bailo <ja*****@texeme.com>
wrote:

Well, it allows for an /interface/ as in a class that can be an
interface with interface methods.

But there is (in Java) no 'interface' type or keyword.

MyClass implements MyInterface

Where MyInterface is just a class built to the rules of a java interface.

Mar 16 '06 #8

P: n/a
John,

Are you sure about this?

Have a brief look at the following page:
http://java.sun.com/docs/books/tutor...erfaceDef.html

Best regards,

Renze de Waal

"John Bailo" <ja*****@texeme.com> schreef in bericht
news:Z7********************@speakeasy.net...

Well, it allows for an /interface/ as in a class that can be an interface
with interface methods.

But there is (in Java) no 'interface' type or keyword.

MyClass implements MyInterface

Where MyInterface is just a class built to the rules of a java interface.

Mar 16 '06 #9

P: n/a
Not to my knowledge. AFAIK Java implements an "interface" concept very
similar to that of C#, complete with the keyword "interface".

Any O-O language that doesn't support multiple inheritance has to
support something like interfaces... single inheritance with no
interface-like concept would hog-tie the programmer.

Mar 16 '06 #10

P: n/a
John Bailo <ja*****@texeme.com> wrote:
Well, it allows for an /interface/ as in a class that can be an
interface with interface methods.

But there is (in Java) no 'interface' type or keyword.

MyClass implements MyInterface

Where MyInterface is just a class built to the rules of a java interface.


No it's not. Try doing that with a class and you get the following
error: "interface expected here".

As Octavio says, Java interfaces are very like .NET interfaces.
Likewise, but have multiple inheritance of interface but single
inheritance of implementation.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 16 '06 #11

P: n/a
John,

In the java definition it states that it is only possible to implement
an interface. Implements with a non-interface is not an option. Do you
have a java compiler that allows you to implement with a
non-interface?

After your post I tried to get the JDK to accept a class definition
that implements a class, but it won't let me do it (the error I get:
interface expected here).

Best regards,

Renze.

On Thu, 16 Mar 2006 12:50:25 -0800, John Bailo <ja*****@texeme.com>
wrote:

What does 'interface' do for me that implements with an non-interface
doesn't?
Renze de Waal wrote:
John,

In JAVA, there is an interface type and keyword.

http://java.sun.com/docs/books/tutor...erfaceDef.html

Best regards,

Renze de Waal.

Mar 16 '06 #12

P: n/a

Well this guy says you can:

http://mindprod.com/jgloss/interface.html

Is he all wet?
Renze de Waal wrote:
John,

In the java definition it states that it is only possible to implement
an interface. Implements with a non-interface is not an option. Do you
have a java compiler that allows you to implement with a
non-interface?

After your post I tried to get the JDK to accept a class definition
that implements a class, but it won't let me do it (the error I get:
interface expected here).

Best regards,

Renze.

On Thu, 16 Mar 2006 12:50:25 -0800, John Bailo <ja*****@texeme.com>
wrote:

What does 'interface' do for me that implements with an non-interface
doesn't?
Renze de Waal wrote:
John,

In JAVA, there is an interface type and keyword.

http://java.sun.com/docs/books/tutor...erfaceDef.html

Best regards,

Renze de Waal.

Mar 16 '06 #13

P: n/a
John Bailo <ja*****@texeme.com> wrote:
What does 'interface' do for me that implements with an non-interface
doesn't?


Try extending multiple classes, then try implementing multiple
interfaces.

(Various things like mocking are also much easier with interfaces,
although that's a separate issue.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 16 '06 #14

P: n/a
John Bailo <ja*****@texeme.com> wrote:
Well this guy says you can:

http://mindprod.com/jgloss/interface.html

Is he all wet?


Well, he's got an error in his code. I've mailed him to let him know -
I suspect if you look at the same page this time tomorrow it will have
been fixed.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Mar 17 '06 #15

P: n/a
Bruce Wood wrote:
[...snip...]
Any O-O language that doesn't support multiple inheritance has to
support something like interfaces... single inheritance with no
interface-like concept would hog-tie the programmer.

[...snip...]

Well, Smalltalk (as a pure OO language) doesn't implement multiple
inheritance and does not know about interfaces. And I don't feel "hog-tied"
at all ;-). But then, Smalltalk isn't statically typed, so I'd like to
modify your statement:

Any statically typed language that doesn't support multiple inheritance
might benefit from something like interfaces.

Interfaces might be necessary to work around problems created by static type
checking. You will propably not need interfaces in dynamically typed
languages.
Mar 17 '06 #16

P: n/a
Bruce Wood wrote:
[...snip...]
Any O-O language that doesn't support multiple inheritance has to
support something like interfaces... single inheritance with no
interface-like concept would hog-tie the programmer.

[...snip...]

Well, Smalltalk (as a pure OO language) doesn't implement multiple
inheritance and does not know about interfaces. And I don't feel "hog-tied"
at all ;-). But then, Smalltalk isn't statically typed, so I'd like to
modify your statement:

Any statically typed language that doesn't support multiple inheritance
might benefit from something like interfaces.

Interfaces might be necessary to work around problems created by static type
checking. You will propably not need interfaces in dynamically typed
languages.
Mar 17 '06 #17

P: n/a
As others have mentioned this is 100% wrong.

Java has an 'interface' keyword.

A "class built to the rules of a java interface" is one that requires
the 'interface' keyword.
public interface TestIF {
void TestSomething();
int TestAlotOfThins();
}

Mar 17 '06 #18

P: n/a
Jon Skeet [C# MVP] wrote:
Well, he's got an error in his code. I've mailed him to let him know -
I suspect if you look at the same page this time tomorrow it will have
been fixed.


Yeah, you're right -- he fixed it.
Mar 17 '06 #19

This discussion thread is closed

Replies have been disabled for this discussion.