Q re Bridge Design Pattern - Abstract Classes vs Interfaces

S

Simon Woods

Hi

I'm just working through (and learning) the standard GoF Design Pattern and
the example of the Bridge pattern on
http://www.dofactory.com/Patterns/PatternBridge.aspx#_self2

I notice at the heart of the real world example is an abstract class

MustInherit Class DataObject
Public MustOverride Sub NextRecord()
Public MustOverride Sub PriorRecord()
Public MustOverride Sub NewRecord(ByVal name As String)
Public MustOverride Sub DeleteRecord(ByVal name As String)
Public MustOverride Sub ShowRecord()
Public MustOverride Sub ShowAllRecords()
End Class

which gets inherited by another class CustomerData which populates itself
with various customers.

I'm wondering why an abstract class is used here rather than an interface.

Could someone help me out pls?

Thanks

Simon
 
A

Armin Zingler

Simon Woods said:
Hi

I'm just working through (and learning) the standard GoF Design
Pattern and the example of the Bridge pattern on
http://www.dofactory.com/Patterns/PatternBridge.aspx#_self2

I notice at the heart of the real world example is an abstract class

MustInherit Class DataObject
Public MustOverride Sub NextRecord()
Public MustOverride Sub PriorRecord()
Public MustOverride Sub NewRecord(ByVal name As String)
Public MustOverride Sub DeleteRecord(ByVal name As String)
Public MustOverride Sub ShowRecord()
Public MustOverride Sub ShowAllRecords()
End Class

which gets inherited by another class CustomerData which populates
itself with various customers.

I'm wondering why an abstract class is used here rather than an
interface.

I wonder, too (not knowing the book). Maybe the base class will be extended
by "content" in the following chapters? Otherwise, I'd probably choose an
Interface.


Armin
 
G

Guest

I'm wondering why an abstract class is used here rather than an
interface.

I guess it gives more flexiblity in the future - you can always extend the
base class with additional features easily (i.e. base implementations).
With an interface, you would need to update the entire project.
 

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