Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Summary

Visual Basic .NET supports inheritance. In addition to defining and implementing interfaces, Visual Basic .NET supports class inheritance. Because of the incorporation of class inheritance in Visual Basic .NET, you now have three kinds of polymorphism to choose from: interface polymorphism, inheritance polymorphism, and abstract poly- morphism.

Use inheritance to support subclassing when you want to generalize an existing class, and use interface polymorphism when you need to support similar capabilities across disparate classes. Abstract classes allow you to combine constraining an interface with inheritance. When you are defining classes, keep an eye out for conditional behavior or select case statements. Type codes that are used to determine dynamic behavior usually suggest code that can benefit from a refinement in the class definitions and polymorphic behavior.

Visual Basic .NET supports single class inheritance and multiple interface inheritance. Classes and interfaces can be combined in whatever manner suits your needs. If a class describes a specialized type of an existing class, use inheritance. Alternatively, if you need to create an adapter that provides access to a concise set of capabilities, implement an interface.

  • + Share This
  • 🔖 Save To Your Account