About using correct terminologi


T

Tony

Hello!

If I have an interface Ia and Ib in this way
interface Ia : Ib
Here we say that interface Ia implements interface Ib

If I have a base class called Base and a derived class called Derived we
have
class Derived : Base
Here we say that the Derived class inherit the Base class

Now to my question if I have an abstract class MyAbstractClass where some
members are abstract like this
class MyClass : MyAbstractClass
Do we say that MyClass inherit or implements

According to me we would say that we implement abstract members from the
MyAbstractClass and
inherit not abstract members but that would mean using both words.

So what is the best terminologi to use(implement or inherit or both) when
the base class is an abstract class

//Tony
 
Ad

Advertisements

M

Marc Gravell

An interface may inherit multiple other interfaces
A class may inherit (subclass) a single other (base) class
A class may implement multiple interfaces
A class may be a concrete subclass of an abstract base class (or any
permutation...)

Marc
 
M

Morten Wennevik [C# MVP]

Personally I would say inherit in all these cases.

Ia inherits Ib (there is no implementation in Ia)
DerivedClass inherits BaseClass even if the base class is abstract
Class implements interface

In VB you are also using the keywords 'Inherits' and 'Implements' in this way.
 
J

Jon Skeet [C# MVP]

An interface may inherit multiple other interfaces
A class may inherit (subclass) a single other (base) class
A class may implement multiple interfaces
A class may be a concrete subclass of an abstract base class (or any
permutation...)

I've never liked "inherit a base class". If you think of normal
personal inheritance, you don't inherit a parent - you inherit items
*from* a parent.

I personally like:

ICollection extends IEnumerable
MemoryStream derives from Stream
Stream implements IDisposable
MemoryStream is a concrete class derived from Stream

The spec says "inherits from" for the interface. (1.9, 13.1.3)

10.3.3 specifies both derivation and extension: "A derived class
extends its direct base class." (I think the subtlety here is that
MemoryStream derives from Object but doesn't extend it; it both
derives from and extends Stream.) Subclass is only used as a noun in
the spec.

Eric Lippert doesn't like "extends" for interfaces:
http://csharpindepth.com/ViewNote.aspx?NoteID=28

(On the page I claim that "extends" is correct as per the spec - I'm
not sure where I got that from though, and I should probably fix it.)

Jon
 
Ad

Advertisements

P

Pavel Minaev

I personally like:

ICollection extends IEnumerable
MemoryStream derives from Stream
Stream implements IDisposable
MemoryStream is a concrete class derived from Stream

The spec says "inherits from" for the interface. (1.9, 13.1.3)

10.3.3 specifies both derivation and extension: "A derived class
extends its direct base class." (I think the subtlety here is that
MemoryStream derives from Object but doesn't extend it; it both
derives from and extends Stream.) Subclass is only used as a noun in
the spec.

Eric Lippert doesn't like "extends" for interfaces:http://csharpindepth.com/ViewNote.aspx?NoteID=28

(On the page I claim that "extends" is correct as per the spec - I'm
not sure where I got that from though, and I should probably fix it.)

I also tend to lean towards either "implies" or "requires" for
interfaces; i.e. "ICollection implies IEnumerable", or "ICollection
requires IEnumerable". In practice, due to the way interfaces are
handled internally in CLR, it makes more sense (have you noticed how,
if you do Type.GetInterfaces(), you get a flat list of all implemented
interfaces, and not just the "most derived" ones?).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top