What's an OOP?

Some ready-made objects added to a window object

REALbasic ready-made objects

Objects also have properties (characteristics). For example, a button has, among others, width, height, position (left and top), and caption properties.

An object's properties can be modified either by entering data into the object's Properties window or by using programming code. For example, to set the caption of Pushbutton1 to "OK" you would use:

PushButton1.caption = "OK"

Basically, then, Object-Oriented Programming (OOP) is done by:

1) putting code into various objects so that they respond to events in desired ways

and

2) by modifying objects' properties so that they are appropriate to the objects' particular jobs in the program.

Object-Oriented Programming is not something to fear. Once you grasp a few basic concepts you will embrace the huge benefit that it affords in terms of programming ease.

First let's be clear about what an object is. Examples of objects that you will be familiar with are: windows, buttons, sliders, etc. In an OOP program these objects respond to events For example, a button can respond to an event (like a user clicking it) by doing something (like making a sound play or a picture appear). How an object responds to an event depends on what you have programmed it to do and the characteristics of the particular object. A button will play a sound if it is clicked only if you have programmed it to do so and it will only respond to a click at all if it is enabled; ie. not greyed out.

 

Objects can hold programming code. In this way an object can be self contained. It can "know" how to respond to events by means of the code it contains.

In the example to the left Pushbutton1 knows what to do if it is clicked (the Action event code tells it how to respond if it is clicked).

Pushbuttons can respond to several different kinds of events. Besides the action event, they can be programmed to respond to any of the events listed below "Action" in the image on the left (Close, DropObject, GotFocus, etc.).