Try OpenEdge Now
skip to main content
Object-oriented Programming
Getting Started with Classes, Interfaces, and Objects : Using the CLASS construct : Defining events within a class : Comparison with procedure-based programming
 
Comparison with procedure-based programming
For procedures, the equivalent of a class event is a named event, which like all procedure resources are weakly typed. Named events have no compile-time definition and are only given a name when they are published at run time. You publish and manage event handler subscriptions for named events using the PUBLISH, SUBSCRIBE, and UNSUBSCRIBE ABL statements, which correspond in function to the Publish( ), Subscribe( ), and Unsubscribe( ) event methods for class events.
The event handlers for named events are always internal procedures (never methods). Thus, you can publish a named event from within a class as long as you publish it on behalf of an external procedure to which the event is attributed, in the same way that you can publish the event from within an external procedure that is different from the external procedure to which the event is attributed. Such a named event is associated with the specified procedure to which the event is attributed, and is not a member of the class that executes the PUBLISH statement. This simply allows you to publish a named event with previously developed event handlers directly from within the class without having to call a separate procedure to do it. For any new development of user-defined events using classes, class events provide the more natural mechanism to implement event-driven applications.