Home -> Programming -> Objects -> What and Why


Advantages of Using Objects

Programs are traditionally code only! The data that the program operates on is kept separate from the code and program. However as programming developed as a discipline the idea of putting them together was introduced. When code and data come together we call it an object. An object contains variables which hold its data, and methods which hold instructions on certain actions that can be performed by the object. In short they are stand alone code modules which have the ability to store information inside themselves and behave in any way which we program them to behave. There are several powerful advantages of using objects in programming.

First, it is a natural way of thinking about things. We all use the idea of objects every day of our lives. A window is an object. It has certain characteristics, such as transparency and size. These properties would be analogous to a programming object's properties (variables). Some windows also have the ability to open. This would be analogous to a programming object's method (behaviour).
Second, they are modular like procedures and functions only more so. Indeed all of the controls in Visual Basic, since VB 2005, are objects and the language is a fully object-oriented language. Making VB 2005 object oriented was a natural extension to the VB language development. Using objects in our programming is a natural extension of a programmers bag of tools and techniques.
Third, objects are more reusable than any other type of code. Code reusability has been one of the Holy Grails of the industry for several decades, but until objects came along it has never been practical. The adjustments which had to be made to the code in order to reuse it in another project, took more time than was saved. Objects, once understood, are simple to create and use, and very easy to reuse.
Fourth, coding is faster when using objects. Object-oriented programs can be built in a fraction of the time that non-object-oriented programs take. The principle reason for this is that much of the programming work has already been done. We are simply linking our objects together to work in a new way. Usually very little coding needs to be sone to the objects themselves. Rather we link them in new and different ways.

Fifth, object-oriented code is easier to maintain and more reliable that non-object-oriented code because of their built-in modularity. You do not have to learn objects, nor do you need to use them. You can do anything in your programs you might want to do without ever using objects. However, they are a natural progression in learning to program and in developing your programming skills.

Characteristics of Objects

Objects are also described in terms of several other characteristics. If you do much with objects you will run into a discussion of the following four characteristics.