Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

12. OOA&D > Abstract Classes & Interfaces

Abstract Classes & Interfaces

An abstract class (implemented in VB using the MustInherit keyword) is very like an interface. It defines the members that must be implemented by an inheriting class but doesn’t usually provide any implementation. So how do you decide which to use? In practice, it isn’t that difficult. Just remember that interfaces represent a CanDo relationship, while classes (abstract or otherwise) represent an IsA relationship.

Let’s look at an example. Remember that weekly production schedule that Neil and Gordon need to prepare? I’ve added it to the basic Recipe class hierarchy. The only relationship the Schedule class has to the other classes in the hierarchy is that it HasA collection of Recipe items, but, like a Recipe, it can print itself.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint