|By Millard F. Brown||
|September 1, 2004 12:00 AM EDT||
PowerBuilder includes a powerful set of foundation classes to speed development. These classes are collectively known as the PowerBuilder Foundation Classes, or PFC. Part 1 of this article provides an introduction to PFC and shows how to use it. For the experienced PFC developer, I'll outline the more recent changes and additions to PFC in Part 2.
This article is not intended as a complete professional reference for PFC - that could be (and is) the subject of an entire book on its own. Nor is it intended as a tutorial, although there are code samples to show you how to use some of the features. What you'll find here is an overview of the architecture, objects, and services of PFC so that you can envision how to use PFC to make your applications more rich, powerful, and user-friendly.
Getting Started with the PFCWhat Is PFC?
PFC is a class library of precoded objects and behavior. PFC provides a head start to application developers as an "out-of-the-box" class library solution.
PFC contains no prebuilt templates. It's a set of base classes that can be extended to provide a more powerful or specialized set of classes. It is a true "foundation" library. Sybase designed PFC with the intention that it would be extended, even though many developers find the provided functionality of the PFC to be ample.
PFC is based on service-based architecture (SBA) and uses simple function calls to enable services. The result is a foundation class library with a great deal of functionality, flexibility, and reusability. It's worth noting, however, that the implementation of PFC uses layers of inheritance that tie many of the objects and references together and prevent individual objects and services from being used without including the majority of PFC objects in your application.
PFC provides basic windows, menus, and user objects. There are also additional user objects that provide services for the developer to use to enhance the functionality of any PFC application.
PFC is more than just the code; it's a complete package. As shipped with PowerBuilder 9, PFC includes:
- PFC Classes
- PFC Help
- PFC Sample Database
- Example program (located in the pfcexamples folder)
- PFC Start Wizard
- Utilities: Library Extender, PFC Message Manager
What Is SBA?PFC uses service-based architecture (SBA), which is a way of building relatively lightweight objects that delegate a great deal of functionality to service objects. Windows and user objects create instances of these nonvisual service objects and request functionality and processing from them. This maximizes the developer's ability to reuse and extend the service objects without needing to modify existing objects and without having to carry around the overhead of fat ancestor objects. See Figure 1 for how objects and services relate to each other.
The traditional inheritance-based model of object construction utilized the capability of object-oriented (OO) languages to extend a base object's functionality by successively adding code in the descendants. This was an improvement over the older "copy-book"- based reuse model of non-OO languages, but there were some significant drawbacks. As the inheritance tree grew and different objects with slightly different capabilities sprouted, it became increasingly difficult to change behaviors, since where to put the new behavior in the inheritance tree was a critical question. In addition, the sheer size of the objects gave rise to the term "fat ancestor." A fat ancestor always carries along the overhead of all of its underlying code whether it needs it or not. It loads slowly and (especially in the 16-bit environment of the time) can cause the compiler to fail if it was too fat. Also, the developer was forced to choose an object out of the hierarchy to fit whatever specialized use was required. If the developer wanted to change the use of the object, it was necessary to replace it with another object from the hierarchy, and painstakingly recode all of his changes.
SBA allows you to do more with less. The ancestor simply carries "hooks" that allow it to make use of functionality contained in smaller, more efficient "service" objects. The service objects can be selectively enabled so that only those services that are actually needed are instantiated. This reduces load time and memory usage. "Object Choice" syndrome is eliminated - the developer uses a single base object and instantiates services as needed to provide desired functionality.
PFC's implementation of SBA uses instance variables in the PFC objects to provide references to service classes. The service classes are instantiated by calling a function, of_set
Placing the code for the linkage service in the window open event ensures that all objects on the window have been fully instantiated. In cases other than the linkage service (which depends on multiple objects being fully instantiated) you would place the code to create a service in the client object's constructor or open event.
PFC ArchitecturePFC is built as a set of visual and nonvisual objects with a layered design. PFC is based on two layers: the PFC and the PFE. Every object in the PFC layer has a descendant in the PFE layer. The PFC layer is where the actual code that implements PFC functionality is placed. The PFE layer is left empty for the developer to modify and extend as necessary. Objects in the PFE layer are named
- Where Are RIA Technologies Headed in 2008?
- PowerBuilder History - How Did It Evolve?
- Creation and Consumption of Web Services with PowerBuilder
- Cloud People: A Who's Who of Cloud Computing
- DDDW Tips and Tricks
- Cloud Expo 2011 East To Attract 10,000 Delegates and 200 Exhibitors
- Working with SOA & Web Services in PowerBuilder
- Dynamically Creating DataWindow Objects
- OLE - Extending the Capabilities of PowerBuilder
- DataWindow.NET How To: Data Entry Form