Visual Basic Programmer
Microsoft Access Database Programmer

Custom Built Software 
Sydney, Australia
Phone Australia
(02) 9453-0456

Object Oriented Programming (OOP) for the Visual Basic.Net Programmer

Object Oriented Programming for the Visual Basic ProgrammerVisual Basic.Net is very different from Visual Basic 6. Whilst the syntax has mostly remained as before, the underlying concepts are very new.

The Visual Basic language now fully supports object-oriented programming including encapsulation, inheritance and polymorphism.

Some of the concepts of OOP should be used in each and every Visual Basic project. And some should be used only with the utmost discretion.

The Basic Concepts of Object Oriented Programming (OOP)

These are the buzz words that the programmer will come across:

  • Objects – these are the fundamental elements in OOP. Objects can interact with other Objects without having to know how or what they do. Forms and controls are objects. Databases are objects.
  • Class – a grouping of Objects of similar type. Classes consist of fields, properties, methods, and events.
  • Encapsulation – the technique of storing data and functions into a single Class.
  • Inheritance – allows Objects to acquire the properties of another Object.
  • Polymorphism – the ability to take more than one form and have different behaviours.

The Advantages of Object Oriented Programming (OOP)

Object-Oriented Programming has the following features:

  • OOP provides a modular structure for defining abstract data types with a defined interface where implementation details are hidden.
  • OOP makes it easy to modify code to create a new object with small differences from the existing object.
  • OOP provides a framework for code libraries which can be easily adapted and modified by the programmer.

The Disadvantages of Object-Oriented Programming (OOP)

The disadvantages of implementing Object Oriented Programming (OOP) are:

  • There is a steep learning curve
  • There is an extensive planning phase
  • The OOP structure, once set, is difficult to change
  • OOP can add layer upon layer of complexity
  • OOP can result in bloated code
  • OOP tends to be over-abstracted, over-engineered and unnecessarily complex
  • Not all Objects can be modelled into the hierarchical structured model of OOP – i.e. Database handling, Accounting software
  • OOP is great for Operating Systems and Language compilers, but not for Business Applications

There are enough negatives to put the Visual Basic programmer on guard. A slavish adherence to OOP will not be productive in the majority of projects that the Visual Basic programmer will ever come across. If not used with discretion, OOP can produce a costly and unmaintainable project.

A selective and cautious approach to Object Oriented Programming (OOP)

By choosing the best of OOP, high Visual Basic programmer productivity can be achieved.

Use the OOP concepts that:

  • Make programming simpler
  • Improve software maintainability
  • Provide faster development times and higher-quality software

And discard the OOP concepts that:

  • Make the programming more complex
  • Take too long to implement

Adapting Object Oriented Programming (OOP) concepts

Encapsulation and Classes are powerful tools, and are essential for the high productive and low maintenance programming effort. The OOP Encapsulation technique should be employed in Visual Basic projects to:

  • Create Classes where the details are hidden and there is a well-defined interface – ensuring isolation of complexity
  • Create Libraries of Classes that can be easily adapted, maintained and reused – eliminating duplicate Code and Procedures

The one technique of OOP that should be used extensively is Encapsulation. This involves storing functions into a Class – or "Black Box". A Class can be likened to a Radio or a TV set – the complexities of transistors, capacitances, resistances, wiring, etc are removed. All the user need to see is an on/off switch, a tuning device and a volume control.

A Library of Classes will incorporate fully the OOP concept of "Encapsulation". Each procedure can be regarded as a "Black Box", carrying out the instructions, without the programmer needing to be aware of what or how it is being carried out.

In the rare occasions that Inheritance or Polymorphism are required (and they should be rare indeed), these odd procedures can be hidden away in a "Black Box".

VB.Net and Object Oriented Programming (OOP): In summary

It is possible to work in an OOP environment and still maintain the highest levels of programming productivity.

Objects, Classes and Encapsulation are the key OOP techniques that the Visual Basic programmer needs. This is very much what has been used since the advent of VB6.

So, use the OOP Objects, Classes and Encapsulation – and forget about the rest.