JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Abstraction, Encapsulation, Inheritance, and Polymorphism

Fields, properties, methods, and events are only one part of OOP. Generally speaking, a language like Visual Basic is object oriented if it supports:

  • Abstraction—The ability to create an abstract representation of a concept in code (as an object named employee is an abstraction of a real employee).

  • Encapsulation—Encapsulation is all about the separation between implementation and interface. In other words, when you encapsulate an object, you make its code and data internal and no longer accessible to the outside except through a well-defined interface. This is also called data hiding.

  • Polymorphism—This is all about creating procedures that can operate on objects of different types. For example, if both person and employee objects have a last_name property, a polymorphic procedure can use that property of both objects. Visual Basic handles polymorphism with both late binding and multiple interfaces, both of which we'll cover.

  • Inheritance—As we've seen, inheritance allows you to derive new classes from other classes. The idea here is that if you were to create, for example, a class for a specific Visual Basic form and then derive a new type of form from that class, the derived class will inherit all the base class's functionality, even before you start adding code or customizing the new form.

In fact, inheritance is such an important topic that the next chapter is dedicated to it. Using inheritance, you can derive a new class, the derived class, from a base class. The derived class inherits all the members of the base class, unless you specifically override them. What's that mean? Take a look at the next topic.

Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor