Oracle Openworld Directory Index
The object inheritance model has not changed since Forms 5.0.
Why Object Orientation?
Hot subject
Ease of analysis and design
Objects parallel the real world
Relational tables do not parallel the real world
Ease of building new apps
The promise of reuse of existing code
Extend and override pre-built behavior and values
Hides the complexity of objects
Promotes use of standards
Ease of maintenance
Change in a master object can affect many child objects
The Bad News
Developer is not really object-oriented
“Object-based” is more accurate
Forms v.5 through v.9i
Forms supports this more than Reports
Inheritance through “subclassing”
Overriding of inherited properties allowed
However, not possible to prevent overriding
The Good News
Developer is not really object-oriented
Since Forms is not truly OO, the object programming features are easier to learn
No fundamental “paradigm shift”
You already know the principles
Forms objects: you may already use subclassing
Forms code: you may already code generically and think parameterically to prepare for reuse
Agenda
OO in Forms
Object-based code
Libraries
Object-based objects
Visual attributes & property classes
Subclassing
Object groups
Object libraries
Templates
Libraries
Familiar concept to most Forms developers
One PLL library can be shared by many forms
Makes updates to code easier
Encapsulation - only package specs are viewable in form
Polymorphism – overloading package program units
Some variable-space sharing between forms is possible
SHARE_LIBRARY_DATA parameter of CALL_FORM, OPEN_FORM, NEW_FORM
Code is dynamically-loaded at runtime
A change to the library might not require recompilation of forms
Use genericization and parameterization to maximize reuse opportunities
Genericizing and Parameterizing
Write the code and test it using specific block and item names
Remove the item names and substitute parameter names
Create a procedure from the code and put it in a package in the same form
Test again
When it works, move it to a library and call it from your Forms code
Tip: Batch Compiling
Run this DOS batch file (in NT or Win 2000) to compile all forms in a directory
Use a similar strategy for menus and libraries
Agenda
OO in Forms
Object-based code
Libraries
Object-based objects
Visual attributes & property classes
Subclassing
Object groups
Object libraries
Templates
Visual Attributes
A set of properties for the display of an object
Font name and font size
Font weight and style
Colors
Create it in the Navigator
Apply the VA to an object
The item or canvas or LOV inherits the VA values
Inherited properties are indicated by arrows
Property Classes
List of selected properties – similar to a VA
Not specific to an object type like a block or item
Does not need to be a full list of properties for the object
Can be attached to an object using the Subclass Information property
For new forms, better to use subclassing from a similar object
You get a full list of properties
For legacy forms, use them if they are there
This was a useful concept pre-v5
Agenda
OO in Forms
Object-based code
Libraries
Object-based objects
Visual attributes & property classes
Subclassing
Object groups
Object libraries
Templates
Subclassing
Allows you to copy property values from another object
You create an object and assign property values
Then you can assign it as a “superclass” object to another object
Three methods
Using the Subclass Information property dialog
Using drag and drop
Using SmartClasses
Drag and Drop Subclassing
Drag from one form and drop in another
The following dialog appears
Click Subclass
Or Ctrl-drag from one node (such as a block) to another in the same form
For example, Item1 from Block1 to Block2
Subclassing With SmartClasses
Defined in the object library
Opens in separate window in Form Builder
Contains objects for reuse
You can mark objects as “SmartClasses”
Use the Object menu
Can group objects
They are then available on the right-click menu for objects
Object Navigator
Layout Editor
Applying a SmartClass
Right-click the object
In Object Navigator
In Layout Editor
Select SmartClasses from menu
This assigns the Subclass Information property
What Is the Effect?
Subclassing via any method creates a reference copy of the properties of the superclass object
Changing the superclass object will change the child upon compiling
All possible non-default properties are referenced
If the property has been assigned it is not default
If the child object has overridden properties, the subclass will not reference those properties
You can override any property after or before subclassing
Subclassing Example
EMPNO item was subclassed from the TXT_ENTER object
Icons indicate the state of the property
Item type is inherited
Enabled is still default
Wrap style is locally overridden
Case Restriction was not part of the superclass
Other Subclassing Techniques
Re-inherit an overridden property by clicking the Inherit button in the toolbar
This will return the value to the control of the superclass
Otherwise, the overridden property will never inherit
You can apply both a subclass and a visual attribute
Provides two sources of inheritance
To copy a subclassed object, use duplicate (Ctrl-D) not copy and paste (Ctrl-C, Ctrl-V)
Otherwise, the inheritance will break
Subclassing Rules
References are dynamic in Form Builder
They are hard-coded into the runtime file, though
Changing the object in the master file does not update the target form automatically
You need to regenerate (compile) the target form
The file with the superclasses must be available when the form is opened in Form Builder
Reference is resolved by name only
In the Forms path or current directory
Not needed for runtime
Tip: Supporting Multiple Standards
References to object libraries are by file name
You can exploit this by creating object libraries with the same name and same objects but different properties
E.g., to support different monitor resolutions, canvases and windows would be different sizes
When generating a particular set of forms, be sure the desired object library is available
To generate against the other object library, hide the first one and make the other one available - in the Forms path
Warnings!
Be prepared for unexpected effects if you disconnect a subclass from an object
Items could change types
For example, a button becomes a text item
Sizes and positions could change
Things could disappear If canvas was inherited
Detaching a trigger may leave a “ghost”
If trigger attached to Smartclass item
Forms object is subclassed from it
Then trigger is removed from superclass
Trigger remains on child item even when the form is reopened or recompiled
Agenda
OO in Forms
Object-based code
Libraries
Object-based objects
Visual attributes & property classes
Subclassing
Object groups
Object libraries
Templates
Object Groups
“A collection of Forms things”
Easy way to package objects
Most useful for subclassing to another form
Drag one thing instead of many things
For example, help system objects
Help text block with buttons and items
Window - preset size
Canvas - preset size and colors
Creating an Object Group
In the Navigator
Select object groups node
Click create
Drag objects from other nodes under the children node
Deleting a child object does not delete the original object
Adding a child object adds it to Forms when they are recompiled or opened in Form Builder
Using an Object Group
Open master (object library or form) in Form Builder
Drag object group from master form to target form
Specify subclass if you want inheritance
Specify copy if you want to change the object later
Agenda
OO in Forms
Object-based code
Libraries
Object-based objects
Visual attributes & property classes
Subclassing
Object groups
Object libraries
Templates
Object Libraries
Separate window in Form Builder
Tab pages contain objects you have created
Two types of objects
Archetypes
SmartClass objects you use as a pattern for other types of objects: items, canvases, windows
Reusable components
Object groups of pre-packaged features
Help system
Calendar
Multi-select window
Creating an Object Library
Plan the types of objects you will use
Create tabs to organize the object
An example later
Create objects in a form
Be sure to add a comment on the object
This will become the comment on the object
Use the Object menu
Package them (in object groups) if needed
Drag objects into the object library
Save the original form as a work area
Object Library Contents
Building blocks
Standard features that are in all forms
Help, alert systems
Standard objects that are in all forms
Windows, canvases, visual attributes
Used for standard code
Startup code, triggers
Object Library Contents
Reusable components
Not required in every form
Drag and drop them in when required
Pre-built “black boxes”
Includes some trigger code
May require attached libraries for more code
Object Library Contents
Archetypes or patterns
Predefined sizes and types
Display items
Text items
List, checkbox, radio group items
Predefined format masks
Dates
Numbers
Currency
Predefined behavior
E.g., updateable or not
Agenda
OO in Forms
Object-based code
Libraries
Object-based objects
Visual attributes & property classes
Subclassing
Object groups
Object libraries
Templates
Forms Templates
A template is a form you base other forms on
Use this as a starting point for your form
Standard .FMB file containing Forms objects
Subclassed from the object library
Attached libraries with common features
Manifestation of the object-based features
Subclassing
Object libraries
Visual attributes
Object groups
Smartclassing
Template System Features
Considerations
Benefits
Lots of functionality with little developer effort
Pre-built objects help use of standards
Provides debugged code
The only efficient way to produce forms apps quickly
Drawbacks
Need Forms expert to develop it
Takes discipline and training to use
Is “too easy” to use
Template System Modules
Template Form
TEMPLATE.FMB
Subclassed object groups from the object library
Alert system
Help system
Visual attributes
Standard parameters
Attached libraries
Reference to standard menu
Create your new forms using File?New ?Form Using Template
Object Library and Form
REFER_FORM.FMB, REFER_OL.FMB
Reference objects
Subclass these into new forms
Using Subclass Information property
Through drag and drop
Through SmartClassing
The form supplies the work area for changes
Drag and drop from the form into the object library
Central location for inspecting and changing properties
Requires discipline to keep it synchronized
Template Libraries
Generic library
Support packages for Forms objects
For example, a procedure to load a poplist with a query
Shared variable space
Support for reusable components
Utilities
Application-specific library
Standard startup (based on security model of application)
Application-specific utilities
Other Files
Help System forms
About window
Help text popup form for displaying help text from a table
TEMPL_MENU.MMB - Template menu
Includes toolbar
Standard menu items
Libraries to support reusable components
Calendar requires separate code
Attached when the component is required
Object library cannot include attached libraries
Icon and graphics files
Company logo
Toolbar icons for standard menu
How to Develop a Template
Think carefully about what to include
Base the template from your standards
Copy an existing template as a pattern
Work with generic objects and code
Do a project using a template
Learn the objects and features
Add to it as you go
Document it!
Code in the Template
Two standard packages
STARTUP
Startup procedures
UTIL
ON-MESSAGE and ON-ERROR handlers
POST_FORM for standard ending routines
Business-specific code
Add other packages based on the application requirements
Keep as much code as possible in the database
Conclusions
This is powerful stuff
You can increase your productivity in Forms many fold
Use the object-based features
Create a template system
Add to it with each project
Think in generic terms for code and objects
Author Information
Paper #102
Web sites
Contain sample code and template files
http://www.quovera.com
http://ourworld.compuserve.com/ homepages/Peter_Koletzke
Oracle Press books, coauthored by Dr. Paul Dorsey
Oracle JDeveloper 3 Handbook
Oracle Advanced Forms and Reports
Oracle Designer Handbook