| < Day Day Up > |
VB has supported abstraction since version 4, and it is actually a simple concept. It is a view of an entity that includes only those aspects that are relevant for a particular situation. In other words, it is the ability of a language to create 'black box' code that takes a concept and creates an abstract representation of that concept within a program.
For instance, suppose we want to create the code that provides services for keeping an employee information database. We'll need to store the following list of items:
ID
IncreaseSalary
DecreaseSalary
Salary
One of the most important ideas to keep in mind is that we included several items in this list for basic information, such as Name and ID. However, we also have an action entity that will be used to increase or decrease salary. These actions are referred to as
Employee Object Name ID IncreaseSalary() DecreaseSalary() Salary End Employee Object
| < Day Day Up > |
| < Day Day Up > |
Encapsulation is the process of taking the abstract representation that we create and encapsulating the methods and properties, exposing only those that are totally necessary from a programmer's standpoint. The properties and
Simply put, this allows a developer to control the methods and properties that are available outside the object.
| < Day Day Up > |
| < Day Day Up > |
VB .NET is the first version of VB that supports inheritance, which is the idea that a class can gain the
When an object is inherited, all of its properties and
Manager Object Inherits Employee Object ManagerPosition End Manager Object
This new
Manager
object will now have the same properties as the
Employee
object (an ID,
| < Day Day Up > |
| < Day Day Up > |
Polymorphism was introduced with VB4. Polymorphism simply means having or passing through many different forms. That is, it is the ability to write one routine that can
Polymorphism allows an inherited method to be overridden. Again, looking at the
Employee
object, we could create a new object that inherits the
Employee
object, but with a new method with the same name as the
IncreaseSalary
method we used earlier. Although the new object would then have the
| < Day Day Up > |