No announcement yet.

What Is An Object Anyway

  • Filter
  • Time
  • Show
Clear All
new posts

  • What Is An Object Anyway

    Please add your comments and suggestions as a Reply to this thread.

    PB/WIN - What is an object, anyway?
    An object is a pre-defined set of data (variables), neatly packaged with a group of subroutines (code) which manipulate the data and provide any other functionality you need.

    For example, a string array containing names and addresses (data) might be packaged with a subroutine (code) that displays a popup dialog to edit the data, another subroutine (code) to print mailing labels, and so forth. That's a great candidate for an object.

    In short, an object is a complete little programming package, code and data, all in one tightly contained place. It's safer and protected, easier to debug, maintain, and reuse. An object can be written to perform most any task you might imagine.

    In object terminology, a CLASS is used to define an object. A CLASS is much like an enhanced user-defined type; it's a description of both the variables and the subroutines which make up the object. When you instruct the compiler to create an object, it uses the definitions found in the CLASS to do so. It allocates memory for the variables, establishes pointers to the subroutines, and makes this new object available to your program.

    Each time you create a new OBJECT, it is called an INSTANCE of its definition (an instance of the CLASS). That's why these variables are called INSTANCE variables. When you create multiple objects (from the same CLASS definition), each instance gets its own individual copy of these INSTANCE variables, and each instance gets individual access to the subroutines.

    In PowerBASIC, objects are optional. Objects are a great programming tool, but your existing code remains fully functional. Standard Subs and Functions will always be supported, so you can blend the techniques at a comfortable pace.

    PowerBASIC objects are practical. They're lightning fast with very little overhead. We've tried very hard to give you the best ratio of straightforward design to performance and features. We think you'll find PowerBASIC objects very hard to resist.

    Thousands of books have been written to describe objects and object oriented programming. In most cases, the buzz words and abstract definitions make it seem as though they're designed to confuse, not enlighten. We'll try to limit the use of strange descriptors, but some of it just can't be avoided. In these cases, we'll try to give you clear definitions as they're needed.

    A key trait of PowerBASIC objects (and objects in general) is the concept of encapsulation. Data is "hidden" within the object, so INSTANCE variables cannot be accessed from the outside.
    INSTANCE variable data may only be set, altered, or retrieved by the subroutines in the object. These variables are hidden from the rest of the program.
    Over the years, objects have gained a reputation for slow, bloated programming. In many cases, this reputation was well deserved. But don't let that fool you. With PowerBASIC, you'll find you have a whole new "Object World"! All the power, yet all the performance, too. PowerBASIC objects give you every ounce of performance possible... the same breathtaking speed as procedural programming!
    See AlsoReferences
    Last edited by Gary Beene; 28 Oct 2014, 10:53 PM.