Getting to Know REALbasic ...
4. Terms Used In The REALbasic Programming Language.
Returning to our house analogy ,,,,,
When you run RB as mentioned in the previous chapter, you see a main window, "Untitled". That window is akin to our RB Construction Company smart house (we will call it "MyHouse"). MyHouse knows how to stand, it won't fall over because it has been pre-engineered. When the RB crew that drops off your container with your house and parts leaves, you are not left alone to assemble your dream home. RB Construction Co. has also left a little assistant, Bob the robot. Bob is here to keep your house building project organized. This is a very good thing because it is easy to misplace things or try and assemble your home in a wrong manner. He will help you with what you would like your project to look and perform like. RB uses tools, code windows and visual clues to help you keep things organized, sorry no actual Bob!
The components or Objects that will be created in your home/project are created by Classes. Programmers work with classes. To be proper, an object is instantiated by its class. You have to decide what Classes your house/project will have. For example, your house needs a front door. Luckily RB Construction has created the Door Class to be added to the house. This Door Class already "knows" how to be a door. How does it know this? Because the good people at RB Construction built it to do act, look and respond as you would expect a door to do.You drag the Door Class out from the container and place it on your smart house. This wakes Bob up. Bob wants to know more information from you about how you want this Door Class to operate and how you want it to look like.. He informs you that this door comes with some built-in Properties of the Door Class.
When you drag a class in RB to the main "Untitled" window, a properties window will appear (usually on the right side of your screen) indicating what properties are available to that Class.What kind of door would you like, an interior or front door? What color would you like the door? The answers you give Bob are the Parameters used for these door properties. The Door Class comes from RB Construction with default values. The kind is Side Door, the color White. You don't like this so you tell Bob what values you would like this door to have. This is how Bob, the robot computer, might interpret your answers:
Most of the RB properties also have default values when they are dragged in to the main window and you are also free to change them. You can even add and define your own properties. Notice that RB helps you to know what properties are available to a particular class. How? Just by listing them in the Properties Window.
Bob needs to be told what to do using the properties that the door class understands. A Roof Class will have different properties associated with it, although it may share some of the properties of the Door Class, perhaps color. The door in this example has only two properties. The parameters it understands are also limited and can be of only of one Type. If you tell Bob that the Color of the door is a Front Door, Bob will complain and tell you that that parameter is not a valid type for that the color property. Bob like all computers are not very bright when it comes to some issues. The details have to be correct. The good news is that RB, just like Bob will let you know when it does not understand something you tell it, usually with a beep and a message box.
Remember, if C++ Construction Company was your home builder, you would have to create this door class and define what properties, parameters and types that it will understand mostly from scratch. This is a daunting programming task for us newbies. The use of classes is at the heart of Object Oriented Programming and is one of the reasons why RB is an excellent choice for us new programmers.
This brings up a very important point that you need to keep in mind and that frankly won't make sense to you yet, but try, it will help you. These are the two Matt Neuburg mantra's. Repeat them as a low guttural murmur to yourself as necessary.
(1) When Bob is still asking you questions about what classes you want in to your house, this is akin to laying out your program in the IDE of RB (refer to the right column definitions) . In the IDE only Classes.
(2) When Bob is done putting all of the classes in to your house, and you tell him that you want to walk around in the house, you may then and only then begin to live in your new home. This is akin to hitting command-R in RB. In your running (or built) application you only have Instances.
Ponder this awhile, we move on to creating a very simple project to emphasize some of the points raised up to this point.
On To Chapter Five ...
Your REALbasic (RB) Learning Library
- Class and Objects
- An Object is instantiated (created) by its Class. In the same way a cookie (Object) is created by its cookie cutter (Class). Each object has the same structure and behavior as the class from which it is instantiated.
- Object Identity
Object identity is the property by which each object can be identified. RB uses the Name property of an object to identify and communicate with an object.
Integrated Development Environment. A fancy acronym for the different windows you see in RB as you create your project.
- Run-Time Environment
When you debug your program by pressing Command-R, you leave the IDE and enter the run-time environment. In other words, your code, with all of its classes, methods and properties has become instantiated (created).