tags:

views:

581

answers:

5

If I have class B : A {}

I say that "Class B inherited class A" or "class B derives from class A".

However, if I instead have:

  class B : ISomeInterface   {}

it's wrong to say "B inherits ISomeInterface" -- the proper term is to say "B implements ISomeInterface".

But, say I have

  interface ISomeInterface : ISomeOtherInterface   {}

Now, it's still wrong to say "inherits", but it's now just as wrong to say "implements" since ISomeInterface doesn't implement anything.

So, what do you call that relationship?

+10  A: 

I personally say "extends" and I thought the C# spec uses that word as well somewhere (I can't find it now, unfortunately) - but I remember Eric Lippert saying he wasn't keen on it, and wanted to change it for 4.0.

I think it's good, because it shows that you're extending the contract specified by the original interface.

EDIT: Having looked at the 3.0 spec...

The spec sort of side-steps the issue in section 13.2. It talks about the members being inherited from the base interfaces. It talks about one class extending another, but not interfaces.

Jon Skeet
Implements implys defining an implementation for an interface. Interfaces have no implementation so that's not possible here. But an interface can extend another interface, which means it can add more methods and inherit its type.+1 for Extends
Tiggerizzy
+4  A: 

I call it "extends".

Alex Martelli
not to be confused with Extendz the male enlargement pill.
RedWolves
+1  A: 

you've got the definition wrong.

B : A means "B inherits from A".

when we say "B implements InterfaceA", that usually means InterfaceA does not have the definition to function - it's only prototypes (or, PURE in C++). However in C++ and most OOPL, the inherit and implement shares same syntax.

So, InterfaceB : InterfaceA still means "InterfaceB inherits InterfaceA".

Francis
+1  A: 

Why would it be wrong to say InterfaceB "inherits" or "derives from" InterfaceA? "Implements" would be wrong, because InterfaceB doesn't provide an implementation. Semantically, deriving interfaces is very similar to deriving classes. C++, for example, doesn't distinguish between interfaces and classes at all.

TheFogger
A: 

Usually, I call it overengineering.

dsimcha
INewerVersion extends IOlderVersion. COldClass implements IOlderVersion but doesn't implement INewerVersion. CNewClass implements INewerVersion. Where's the overengineering?
Windows programmer
@Windows programmer: This is a good exception. Hence, the **usually** overengineering. First of all, this was somewhat tongue-in-cheek. Secondly, when you have interfaces inheriting from interfaces, you've got at least three levels of inheritance because someone's going to implement those interfaces too. That's starting to get up there.
dsimcha