[futurebasic] Re: Fear and Loathing Guide

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 1997 : Group Archive : Group : All Groups

From: Scott at JMar <jmar@...>
Date: Thu, 27 Nov 97 09:50:18 -0800
>I have yet to figure out what the advantage to objects are, let alone
>exactly what objects are.

It's really the terminology that makes OOP confusing.  However the 
concept behind OOP is intuitive because it is attempting to mimic the 
real world.

Let me make a stab at this:

Object Oriented Programming  (OOP) is actually a way to make programming 
easier by reflecting the real world.  In the real world there are objects 
which have properties and behaviour and interact with each other.  In 
OOP, objects also have properties and behaviour.

For example, in the real world, there is a class of vehicles called 
motorcycles.  Each "instance" of this motorcycle "class" is an actual 
Motorcycle "object" which has properties and behaves in certain ways.  So 
one could define the class of "Motorcycle" (which is a subclass of class 
"Vehicle") like this.

(Note: I'm assuming a lot for proper syntax and coding here.)

BEGIN CLASS "Motorcycle","Vehicle"

     ' first define properties of your object
     DIM Make
     DIM Color
     DIM engineState

     PROPERTY Make
     PROPERTY Color
     PROPERTY engineState

     ' define class behaviour next
     BEGIN METHOD startEngine
          LONG IF engineState = _true
               PRINT "The engine is already on"
               engineState = _true
               PRINT "The engine is now on."
          END IF


Now create your particular motorcycle object (an instance of the 
Motorcycle class):


and set it's properties :

     myBike.Make = "Yamaha RZ350"
     myBike.Color = "Blue"

The last statement should result in "The engine is now on" if the engine 
was off (ie, engineState = _false).

You can make as many motorcylcle objects as you want with different 

     bike1. Motorcycle
     bike2. Motorcycle
     bike3. Motorcycle

all with different properties but the same behaviour.

Actually, much of this is nothing new because FB's records are really 
objects which have properties (values) defined.  You create a "Record" 
class, define individual records, and assign values.  But with FB^3, we 
will now be able to define behaviour for these records, making them more 
true to life.