Title: PowerBuilder Foundation Class: A Service Orientated Framework
1PowerBuilder Foundation ClassA Service
Orientated Framework
- Sea Bass Software Limited
- www.seabass.co.uk
2Introduction
- David Hargreaves
- david.hargreaves_at_seabass.co.uk
- Sea Bass Software Limited
- www.seabass.co.uk
3Topics for Discussion
- PFC Architecture
- Using PFC Services
- Adding Additional Services
4PFC Architecture
- Evolution of Frameworks
- Service Orientated Framework
5Evolution of Frameworks
- General Purpose Framework
- Nest Generalisation Framework
- Service Orientated Framework
6General Purpose Framework
- All functionality in one ancestor
- Turn functionality on using functions
- Functionality provided through instance variables
7General Purpose Framework
Ancestor Window
boolean ib_sort FALSE boolean ib_filter FALSE
...
of_SetSort(TRUE) of_SetFilter(TRUE) ...
IF ib_sort THEN Sort code END IF IF ib_filter
THEN Filter code END IF
8Nested Generalisation Framework
- Ancestor class contains generic functionality
- Descendent classes add specific functionality
- Functionality enabled by selecting required
descendant
9Nested Generalisation Framework
10Service Orientated Framework
- Functionality is encapsulated in service classes
- Requestor classes delegate work to service
classes - Uses the Client/Server model
11Service Orientated Framework
Services
Requestor
Base
Sort
Filter
12PFC Architecture Summary
- Code is encapsulated in service classes
- Requestor calls services when required
- Smaller hierarchy
- Maintenance is easier
- Quicker compilation time
- No duplication of code
- High level of reuse
13Using PFC Services
- Service Classes
- Requestor Classes
- Creating Services
- Delegating Work to Services
14Service Classes
- Perform work specific to the service
- Maintains a link to the requestor object
15Service Classes
n_cst_dwsrv_sort
u_dw idw_requestor ...
of_SetRequestor(u_dw adw_requestor) idw_requestor
adw_requestor ...
pfc_clicked(xpos, ypos, row, dwo) This.of_Sort()
...
of_Sort() idw_requestor.Sort() ...
16Requestor Classes
- Owns service objects
- Create service objects required
- Maintains a link to the service object
- Delegates work to the service object
- Destroys the service object
17Requestor Classes
u_dw
n_cst_dwsrv_sort inv_sort ...
of_SetSort(boolean ab_switch) inv_sort Create
n_cst_dwsrv_sort inv_sort.of_SetRequestor(This)
...
clicked(xpos, ypos, row, dwo) IF IsValid
(inv_Sort) THEN inv_Sort.Event pfc_clicked
( xpos, ypos, row, dwo ) END IF ...
18Creating Services
- Requestor object owns the service object
- Requestor object creates the service (two way
link) - Requestor contains pre-defined instance variables
to point to service - Pre-defined requestor functions allowing the
service to be created
19Creating Services
u_dw (requestor)
n_cst_dwsrv_sort inv_sort
... of_SetSort(TRUE) inv_sort Create
n_cst_dwsvr_sort inv_sort.of_SetRequestor(This)
...
n_cst_dwsvr_sort (service)
u_dw idw_requestor
... idw_requestor adw_requestor ...
20Demonstration
- Create the default sort service
- Create the default filter service
21Delegating Work to Services
- Work is delegated using pre-defined methods in
Requestor and Service objects - Delegation Types
- Pre-defined delegation
- User-defined delegation
22Pre-defined Delegation
- Requestor Pre-coded events
- PowerBuilder events
- PFC events called from menu
- Service Pre-coded events
- Re-directed from requestor
23Pre-defined Delegation
u_dw (requestor)
n_cst_dwsrv_sort inv_sort
IF IsValid (inv_Sort) THEN inv_Sort.Event
pfc_clicked ( xpos, ypos, row, dwo ) END IF
n_cst_dwsvr_sort (service)
u_dw idw_requestor
... idw_Requestor.Sort() ...
24User-defined Delegation
- Service pre-coded functions
- Requestor delegates work to service
- Used to change the state of a service
25User-defined Delegation
u_dw (requestor)
n_cst_dwsrv_sort inv_sort
This.of_SetSort(TRUE) IF IsValid(inv_Sort)
THEN inv_Sort.of_SetStyle(inv_sort.dragdrop) END
IF
n_cst_dwsvr_sort (service)
integer ii_style
... ii_style ai_style ... Return 1
26Demonstration
- Assign the DRAGDROP style to the sort service
- Assign the EXTENDED style to the filter service
- Create the calendar service on the joining date
- Create the calculator service on the salary
27Using PFC Services Summary
- Service Classes encapsulate functionality
- Requestor Classes call required services
- Pre-defined delegation has been coded into the
PFC - User-defined delegation changes the default style
of the service
28Adding Additional Services
- Create Additional Service Objects
- Create Service Object
- Instance variables
- Functions
- Events
- Add New Service to Requestor
- Instance variable
- Create/Destroy function
- Re-direct calls to service
29Create Additional Service Objects
pfc_w_master
pfc_n_base
w_master
n_base
pfc_w_response
pfc_n_cst_dwsrv
w_response
n_cst_dwsrv
w_column_dragdrop
n_cst_dwsrv_column
30Demonstration
- Create a DataWindow service to allow columns to
be moved during runtime - Create a column service object
- Create a column service attribute object
- Create a column drag and drop window
31Create Service Functions
- Encapsulate functionality
- Protected instance variables
- Protected functions
- Enable the requestor to customise the service
- Protected instance variables
- Public functions to change variables
32Create Service Functions
n_cst_dwsrv_column (Extension Layer)
string is_excludecolumns
Public of_setexclude (string as_excludecols) of
_getexclude (ref string as_excludecols) Protect
ed of_buildcolumnattrib ( ref
n_cst_columnattrib anv_columnattrib) ...
33Demonstration
- Create the column service functionality
- Create the required instance variables
- Create the public interface, such as get/set
functions - Create the column functionality
34Create Service Events
- Create user events for requestor redirection
- Process service functionality
- Call additional service objects
- Ensure a return code is provided
35Create Service Events
n_cst_dwsrv_column (Extension Layer)
event pfc_column()
... IF NOT IsValid(idw_requestor) THEN li_rc
-1 ELSE li_rc This.of_SetColumn() END
IF RETURN li_rc
36Demonstration
- Create the column service events
- Create a pfc_columndlg event to call the
drag-drop window
37Add New Service to Requestor
- Add instance variable for service
- Add of_Set() function to enable service
- Re-direct events to service
38Add New Service to Requestor
u_dw (Extension Layer)
n_cst_dwsrv_column inv_column ...
Public of_setcolumn(boolean ab_switch)
pfc_columndlg event IF IsValid(inv_column)
THEN inv_column.Event pfc_columndlg() END IF ...
39Demonstration
- Create the requestor service calls
- Create service instance variable
- Create function to turn service on/off
- Create a pfc_columndlg event to call the column
service
40Creating Services
- Requestor object owns the service object
- Requestor object creates the service (two way
link) - Requestor contains pre-defined instance variables
to point to service - Pre-defined requestor functions allowing the
service to be created
41Creating Services
u_dw (requestor)
n_cst_dwsrv_column inv_column
... of_SetColumn(TRUE) inv_column Create
n_cst_dwsvr_column inv_column.of_SetRequestor(Thi
s) ...
n_cst_dwsvr_column (service)
u_dw idw_requestor
... idw_requestor adw_requestor ...
42Demonstration
- Create the column service to allow columns to be
moved during runtime - Add a button to call the service
43Adding Additional Services Summary
- Create new service objects
- Create events for redirection and functions to
encapsulate functionality - Create requestor links to service object
- Instance variable
- Create/Destroy function
- Re-direct functionality
44Questions and Answers
- David Hargreaves
- david.hargreaves_at_seabass.co.uk
- Sarah Bell - Business Manager
- sarah.bell_at_seabass.co.uk
- (01491) 682585
- Web Site
- www.seabass.co.uk