In object-oriented programming, you create reusable classes to perform application processing. These classes include properties and methods that define the class’s behavior. To perform application processing, you create objects, which are instances of these classes. PocketBuilder implements these concepts as follows:
The rest of this chapter uses this PocketBuilder terminology.
Object-oriented programming tools support three fundamental principles: inheritance, encapsulation, and polymorphism.
Inheritance Objects can be derived from existing objects, with access to their visual component, data, and code. Inheritance saves coding time, maximizes code reuse, and enhances consistency. An object derived from an existing object is called a descendent object or a subclass.
Encapsulation An object contains its own data and code, allowing outside access as appropriate. This principle is also called information hiding. PocketBuilder enables and supports encapsulation by giving you tools that can enforce it, such as access and scope. However, PocketBuilder itself does not require or automatically enforce encapsulation.
Polymorphism Functions with the same name behave differently, depending on the referenced object. Polymorphism enables you to provide a consistent interface throughout the application and within all objects.
Many current applications make heavy use of object-oriented features for visual objects such as windows, menus, and visual user objects. This allows an application to present a consistent, unified look and feel.
To fully benefit from PocketBuilder’s object-oriented capabilities, consider implementing class user objects, also known as nonvisual user objects:
Standard class user objects Inherit their definitions from built-in PocketBuilder system objects, such as Transaction, Message, or Error. Creating customized standard class user objects allows you to provide powerful extensions to built-in PocketBuilder system objects.
Custom class user objects Inherit their definitions from the PocketBuilder NonVisualObject class. Custom class user objects encapsulate data and code. This type of class user object allows you to define an object class from scratch. To make the most of PocketBuilder’s object-oriented capabilities, you must use custom class user objects. Typical uses include:
Global variable container The custom class user object contains variables and functions for use across your application. You encapsulate these variables as appropriate for your application, allowing access directly or through object functions.
Service object The custom class user object contains functions and variables that are useful either in a specific context (such as a DataWindow) or globally (such as a collection of string-handling functions).
Business rules The custom class user object contains functions and variables that implement business rules. You can either create one object for all business rules or create multiple objects for related groups of business rules.