• Save
Booa8 Slide 02
Upcoming SlideShare
Loading in...5

Booa8 Slide 02






Total Views
Views on SlideShare
Embed Views



1 Embed 12

http://aulavirtual.ingenieriausp.com 12



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

Booa8 Slide 02 Booa8 Slide 02 Presentation Transcript

  • Buliding Object-Oriented Applications in PowerBuilder Module 2: Objects And Classes
  • Objectives
    • Define Object and Classes
    • Use Edit Source (system tree) / Export Syntax (Iibrary painter) to view the definition of classes
    • Add Properties and Methods to a class
  • Topics: Objects and Classes
    • Definitions
    • Defining Classes
    • Viewing Class Definitions
    • What Can Be Added to a Class
    • Adding Properties to a Class
    • Adding Methods to a Class
  • Objects — Definition
    • An object is represented by its:
      • Properties: Visible, color, height
      • Property values (data): George, red, 5'8"
      • Methods (behaviors): Pitches a baseball, eats anchovy pizza
  • Classes — Definition
    • A class defines a set of objects
    • Each object is an instance of its class
    Class Definition Object Instance
  • Defining Classes
    • Done in Painters
      • Window
      • Menu
      • User-Object
      • Application
    • Based on Inheritance
  • New Objects Created Through Inheritance
  • Defining Classes
    • Stored in PBLs, PBDs, DLLs, and EXEs
  • Syntax — Window Subclass of window class Class properties changed
  • Defining Classes
    • User-defined classes of applications, menus, user objects, and windows can:
      • Have new properties (instance variables)
      • Have new methods (events, object functions, and local external functions)
  • Adding Properties — Instance Variables
  • Methods of a Class
    • Methods are object behaviors
    • Represented by scripts associated with:
      • Events
      • Functions
  • System Methods
    • Mapped to specific event ids.
    • You cannot add / change arguments
    Show/Hide Prototype Cannot Modify Arguments
  • Adding Methods — Events
    • An event is a notification that an action has occurred
    • System events are operating system or PowerBuilder events
      • Examples: Clicked, Open, Constructor, RButtonDown, RetrieveStart, DBError
    • User-defined events can be:
      • Added to windows, user objects, and window controls
      • Mapped to system events or unmapped
  • User-Defined Events
  • Mapped Events
    • Predefined events
      • Dependent on operating system
      • ue_downkey ---> pbm_dwnkey
    • Arguments and return data type are predefined
  • Unmapped Events
    • An unmapped event:
      • Is independent of system and PowerBuilder events
      • Is invoked via scripts only
      • Supports user-defined arguments and a user-specified return data type
  • User-Defined Events Mapped or Unmapped Events Determined
  • Adding Methods — Functions
    • Built-in functions:
      • System (Global) functions
      • Class functions
    • User-defined functions:
      • Object functions
      • External functions
  • Adding Methods — Object Functions
    • Functions defined for a class are methods
    • A function definition consists of:
      • Name
      • Return data type (optional)
      • Arguments and their data types (optional)
      • Script (optional)
      • Access privilege
    • Can be defined for Application, Menu, Window, and UserObject classes
  • Adding Functions
  • Adding Functions
  • Adding Methods — External Functions
    • Reside in DLLs or EXEs
    • Created outside of PowerBuilder (for example, using C++)
    • Must be declared to PowerBuilder
    • Can be called as any other function
    • Can be global or local
    • Can be defined at the object level for menus, user objects, and windows
  • Adding Methods — External Functions
  • Summary Events Yes (v8) Yes (v8) Yes Yes Yes Class Application Menu UserObject Window Window control Instance Variables Yes Yes Yes Yes No Object Function Yes Yes Yes Yes No External Function No Yes Yes Yes No
  • Summary
    • A class has a name, properties, and methods.
    • A class is the definition of a set of objects.
    • An object is an instance of a class.
    • The four main PowerBuilder painters are: Application, Menu, User Object, and Window.
    • PowerBuilder class definitions are stored in libraries:
      • PBLs for development
      • PBDs, DLLs and EXEs for an executable
  • Summary Questions
  • Lab Setup
    • What you will need to do the lab:
      • Set the application search path
      • Connect to the Database
      • Add properties to a class as instance variables
      • Add function methods to a class Preview a window
  • Lab Debriefing
    • Created two instance variables: is_action and il_key
  • Lab Debriefing
    • Created two methods to set properties
  • Lab Debriefing
    • Created two methods to get properties
  • Lab Debriefing
    • But we have not fully encapsulated these properties. (more in later chapters)
    Can you access these properties using direct access? Should you? But can you? What are some disadvantages of not fully encapsulating these?