Groups | Blog | Home
all groups > dotnet general > march 2004 >

dotnet general : interfaces and abstract classes


doknjas NO[at]SPAM telus-dot-net.no-spam.invalid
3/9/2004 10:39:38 PM
In addition to what Mattias said, there is a real conceptual
difference between the two. An abstract class forms the base for an
"is a " relationship, while an interface is a role an object takes
on.

e.g., a door is a "WoodenObject", and it operates in the role of a
"Lockable" device. A window also takes on the same role, but is not
a WoodenObject.

You could use an interface where an abstract class is more appropriate
and make it work, but it would be confusing to others. Take a look
at the interfaces defined within .NET and you'll see that they are
roles, not base identities.


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
ichor
3/9/2004 10:51:27 PM
what is hte difference between the 2?
i am reading wrox professional c# and fail to understand the difference
between teh 2?

Mattias Sjögren
3/10/2004 2:16:34 AM

[quoted text, click to view]

An abstract class can have data fields and non-abstract members, an
interface can't.

A class can derive only from a single class, but implement multiple
interfaces.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
ichor
3/10/2004 5:32:22 PM
thanx doknjas..
what u say makes so much sense..
i would like to delve deep into object oriented c# ..
are there any good resources i can look at..
including buying good books

thanx

[quoted text, click to view]

doknjas NO[at]SPAM telus-dot-net.no-spam.invalid
3/11/2004 12:39:37 AM
I've found "Programming C#" by Jesse Liberty (published by O'Reilly)
quite useful.

I also use Instant C# (www.instantcsharp.com) to convert VB code to
C#, since I have a lot of VB production and sample code sitting
around, being a VB programmer for 10 years. Also, when I dig up an
example in VB, I don't have to waste time looking for the C# version.


Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
AddThis Social Bookmark Button