Principles of Object-Oriented Programming

It is often said that there are four main concepts in the area of object-oriented programming:

  • Abstraction

  • Encapsulation

  • Inheritance

  • Polymorphism

Each of these concepts plays a significant role in VB .NET programming at one level or another. Encapsulation and abstraction are “abstract” concepts providing motivation for object-oriented programming. Inheritance and polymorphism are concepts that are directly implemented in VB .NET programming.

Abstraction

Simply put, an abstraction is a view of an entity that includes only those aspects that are relevant for a particular situation. For instance, suppose that we want to create a software component that provides services for keeping a company’s employee information. For this purpose, we begin by making a list of the items relevant to our entity (an employee of the company). Some of these items are:

  • FullName

  • Address

  • EmployeeID

  • Salary

  • IncSalary

  • DecSalary

Note that we include not only properties of the entities in question, such as FullName, but also actions that might be taken with respect to these entities, such as IncSalary, to increase an employee’s salary. Actions are also referred to as methods, operations, or behaviors. We will use the term methods , since this term is used by VB .NET.

Of course, we would never think of including an IQ property, since this would not be politically correct, not to mention discriminatory and therefore possibly illegal. Nor would we include a property called HairCount, ...

Get VB .NET Language in a Nutshell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.