END METHOD. - Progress Community

advertisement
Leveraging Design Patterns in ABL
Applications
Phillip Magnay
Technical Architect
Goals of this Session
What are the take-aways?
 Many common design problems already have



2
tried and proven solutions
Some wheels have already been invented
Design patterns exist in the public domain
Design patterns can be readily implemented in
OpenEdge® ABL
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Agenda
What we’re going to cover…
 What are Design Patterns?
 Origins & Background
 Benefits
 Design Pattern Classifications
 Documenting Design Patterns
 Implementing Design Patterns in ABL
 Limitations of Design Patterns
3
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
What are Design Patterns?
 Repeatable solution to a software design problem
 Design “template”
 Relationships & interactions between classes


and/or objects
Situation dependent, must be adapted
Not all patterns are “design” patterns
• Architectural pattern
• Code pattern
4
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Origins & Background
 Patterns in architecture during the ’70s
 Programming patterns in the ’80s
 Object-Orientation in the ’90s
 Gang of Four (Gof) in 1994
• Design Patterns: Elements of Reusable
Object-Oriented Software
 Pattern Languages
 Pattern Repositories
5
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Benefits
 Accelerates the development process
 Tested & proven approaches
 Familiar to developers
 Provides a lexicon, facilitates communication
 Basis for standards and documentation
6
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Design Pattern Classifications
 Creational Patterns
 Structural Patterns
 Behavioral Patterns
 Fundamental Patterns
 Meta- Patterns
 Architectural Patterns
7
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Gang of Four Patterns

Structural Patterns
•
Adapter

Creational Patterns
•
•
•
•
•
Abstract Factory
Builder
Factory Method
Prototype
Singleton
8
Leveraging Design Patterns in ABL Applications
•
•
•
•
•
•
Bridge
Composite
Decorator
Façade
Flyweight
Proxy

Behavioral Patterns
•
•
•
•
•
•
•
•
•
•
•
Chain of responsibility
Command
Interpreter
Iterator
Mediator
Memento
Observer
State
Strategy
Template method
Visitor
© 2007 Progress Software Corporation
Design Pattern Documentation
 Pattern Name
 Classification
 Also Known As (AKA)
 Motivation
 Applicability
 Structure
 Participants
 Collaboration
9
Leveraging Design Patterns in ABL Applications
 Consequences
 Implementation
 Sample Code
 Known Uses
 Related Patterns
© 2007 Progress Software Corporation
Implementing Design Patterns in ABL
 Factory Method
 State
 Decorator
 Observer
 Command
10
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Factory Method Pattern
Name:
Classification:
Factory Method
Creational
Motivation:
Need to define a standard interface to create
objects, but allow sub-classes decide which
class to instantiate.
A class cannot anticipate the class of objects
it must create.
Product, ConcreteProduct, Creator,
ConcreteCreator
Applicability:
Participants:
11
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Factory Method Pattern Structure
12
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Factory Method Pattern Example
13
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Factory Method Pattern Example
CLASS Account:
METHOD PUBLIC VOID Deposit
(INPUT amt AS DECIMAL):
/* code */
END METHOD.
METHOD PUBLIC VOID Withdraw
(INPUT amt AS DECIMAL):
/* code */
END METHOD.
METHOD PUBLIC VOID PayInterest
(INPUT rate AS DECIMAL):
/* code */
END METHOD.
END CLASS.
14
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Factory Method Pattern Example
CLASS PersonalAccount INHERITS Account:
METHOD PUBLIC OVERRIDE VOID Withdraw
(INPUT amt AS DECIMAL):
/* code */
END METHOD.
METHOD PUBLIC OVERRIDE VOID PayInterest
(INPUT rate AS DECIMAL):
/* code */
END METHOD.
END CLASS.
15
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Factory Method Pattern Example
CLASS BusinessAccount
INHERITS Account:
METHOD PUBLIC OVERRIDE VOID Deposit
(INPUT amt AS DECIMAL):
/* code */
END METHOD.
METHOD PUBLIC OVERRIDE VOID PayInterest
(INPUT rate AS DECIMAL):
/* code */
END METHOD.
END CLASS.
16
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Factory Method Pattern Example
CLASS BankBranch:
METHOD PUBLIC Account CreateAccount():
/* code */
END METHOD.
END CLASS.
17
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Factory Method Pattern Example
CLASS RetailBranch INHERITS BankBranch:
METHOD PUBLIC OVERRIDE Account CreateAccount():
DEF VAR rAccount AS
CLASS PersonalAccount NO-UNDO.
rAccount = NEW PersonalAccount().
RETURN rAccount.
END METHOD.
END CLASS.
18
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Factory Method Pattern Example
CLASS CommercialBranch INHERITS BankBranch:
METHOD PUBLIC OVERRIDE Account CreateAccount():
DEF VAR rAccount AS
CLASS BusinessAccount NO-UNDO.
rAccount = NEW BusinessAccount().
RETURN rAccount.
END METHOD.
END CLASS.
19
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Factory Method Pattern Example
Main:
DO:
DEF VAR rBranch AS CLASS BankBranch NO-UNDO.
DEF VAR rAccount AS CLASS Account
NO-UNDO.
rBranch
= NEW RetailBranch().
rAccount
= rBranch:CreateAccount().
rAccount:deposit(1000.00).
rAccount:withdraw(500.00).
rAccount:payInterest(5.25).
rBranch
= NEW CommercialBranch().
rAccount
= rBranch:CreateAccount().
rAccount:deposit(1000.00).
rAccount:withdraw(500.00).
rAccount:payInterest(5.25).
END.
20
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
State Pattern
Name:
Classification:
State
Behavioral
Motivation:
Allow an object to alter its behavior at runtime when its internal state changes.
An object must change it behavior at run-time
depending on its internal state.
Applicability:
Participants:
21
Context, State, ConcreteState subclasses
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
State Pattern Structure
22
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
State Pattern Example
23
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
State Pattern Example
CLASS Account:
DEF PRIVATE VAR rState
AS CLASS AccountState NO-UNDO.
DEF PUBLIC VAR balance AS DECIMAL NO-UNDO.
CONSTRUCTOR PUBLIC Account ():
checkState().
END CONSTRUCTOR.
METHOD PUBLIC VOID Deposit(INPUT amt as DECIMAL):
rState:Deposit(amt).
checkState().
END METHOD.
METHOD PUBLIC VOID Withdraw(INPUT amt AS DECIMAL):
rState:Withdraw(amt).
checkState().
END METHOD.
METHOD PUBLIC VOID CalcInterest():
rState:CalcInterest().
checkState().
END METHOD.
…
24
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
State Pattern Example
…
METHOD PRIVATE VOID checkState():
IF balance < 0 THEN
DO:
IF rState <> ? THEN
DELETE OBJECT rState.
rState = NEW OverdrawnState(THIS-OBJECT).
END.
ELSE IF balance >= 0 AND balance < 1000 THEN
DO:
IF rState <> ? THEN
DELETE OBJECT rState.
rState = NEW NonInterestState(THIS-OBJECT).
END.
ELSE
DO:
IF rState <> ? THEN
DELETE OBJECT rState.
rState = NEW InterestState(THIS-OBJECT).
END.
END METHOD.
END CLASS.
25
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
State Pattern Example
CLASS AccountState:
DEF PROTECTED VAR rAccount
AS CLASS Account NO-UNDO.
CONSTRUCTOR PUBLIC AccountState
(INPUT acc AS CLASS Account):
rAccount = acc.
END CONSTRUCTOR.
METHOD PUBLIC VOID Deposit
(INPUT amt AS DECIMAL):
rAccount:balance = rAccount:balance + amt.
END METHOD.
METHOD PUBLIC VOID Withdraw
(INPUT amt AS DECIMAL):
rAccount:balance = rAccount:balance - amt.
END METHOD.
METHOD PUBLIC VOID CalcInterest():
/* To be overridden */
END METHOD.
END CLASS.
26
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
State Pattern Example
CLASS NonInterestState INHERITS AccountState:
CONSTRUCTOR PUBLIC NonInterestState
(INPUT acc AS CLASS Account):
SUPER(acc).
END CONSTRUCTOR.
METHOD PUBLIC OVERRIDE VOID CalcInterest():
/* do nothing, no interest */
END METHOD.
END CLASS.
27
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
State Pattern Example
CLASS InterestState INHERITS AccountState:
CONSTRUCTOR PUBLIC InterestState
(INPUT acc AS CLASS Account):
SUPER(acc).
END CONSTRUCTOR.
METHOD PUBLIC OVERRIDE VOID CalcInterest():
rAccount:balance = rAccount:balance +
(rAccount:balance * 0.0325).
END METHOD.
END CLASS.
28
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
State Pattern Example
CLASS OverdrawnState INHERITS AccountState:
CONSTRUCTOR PUBLIC OverdrawnState
(INPUT acc AS CLASS Account):
SUPER(acc).
END CONSTRUCTOR.
METHOD PUBLIC OVERRIDE VOID Withdraw
(INPUT amt AS DECIMAL):
/* overdrawn, do not change balance */
END METHOD.
METHOD PUBLIC OVERRIDE VOID CalcInterest():
rAccount:balance = rAccount:balance –
(rAccount:balance * 0.1325).
END METHOD.
END CLASS.
29
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
State Pattern Example
Main:
DO:
DEF VAR rAccount AS CLASS Account
NO-UNDO.
rAccount = NEW Account().
rAccount:CalcInterest().
rAccount:Deposit(500.00).
rAccount:CalcInterest().
rAccount:Deposit(600.00).
rAccount:CalcInterest().
rAccount:Withdraw(200.00).
rAccount:CalcInterest().
rAccount:Withdraw(1000.00).
rAccount:CalcInterest().
END.
30
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Decorator Pattern
Name:
Classification:
Decorator
Structural
Motivation:
Attach additional functionality to an object
dynamically
When extension is required without impacting
other classes and subclassing is difficult.
Applicability:
Participants:
31
Component, ConcreteComponent,
Decorator,ConcreteDecorator
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Decorator Pattern Structure
32
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Decorator Pattern Example
33
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Decorator Pattern Example
CLASS Account:
DEF PROTECTED PROPERTY balance
AS DECIMAL NO-UNDO GET. SET.
CONSTRUCTOR PUBLIC Account():
balance = 0.
END CONSTRUCTOR.
METHOD PUBLIC VOID Withdraw
(INPUT amt AS DECIMAL):
/* to be overridden */
END METHOD.
END CLASS.
34
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Decorator Pattern Example
CLASS CheckingAccount INHERITS Account:
METHOD PUBLIC OVERRIDE VOID Withdraw
(INPUT amt AS DECIMAL ):
balance = balance - amt.
END METHOD.
END CLASS.
35
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Decorator Pattern Example
CLASS AccountDecorator INHERITS Account:
DEF PROTECTED VAR rAccount
AS CLASS Account NO-UNDO.
CONSTRUCTOR PUBLIC AccountDecorator
(INPUT acc AS CLASS Account):
rAccount = acc.
END CONSTRUCTOR.
METHOD PUBLIC OVERRIDE VOID Withdraw
(INPUT amt AS DECIMAL):
rAccount:Withdraw(amt).
END METHOD.
END CLASS.
36
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Decorator Pattern Example
CLASS AuditedAccount
INHERITS AccountDecorator:
CONSTRUCTOR PUBLIC AuditedAccount
(INPUT acc AS Account):
SUPER(acc).
END CONSTRUCTOR.
METHOD PUBLIC OVERRIDE VOID Withdraw
(INPUT amt AS DECIMAL):
SUPER:Withdraw(amt).
AuditWithdrawal(amt).
END METHOD.
METHOD PRIVATE VOID AuditWithdrawal
(INPUT amt AS DECIMAL):
/* some auditing code */
END METHOD.
END CLASS.
37
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Decorator Pattern Example
Main:
DO:
DEF VAR rAccount
AS CLASS Account NO-UNDO.
DEF VAR rAuditedAccount AS CLASS AuditedAccount NO-UNDO.
rAccount = NEW Account().
rAccount:Withdraw(1000.00).
rAuditedAccount = NEW AuditedAccount(rAccount).
rAuditedAccount:Withdraw(1000.00).
END.
38
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Observer Pattern
Name:
Classification:
Observer
Behavioral
Motivation:
Establish a one-to-many relationship
between objects so that a state change in
one object notifies all related objects.
When a state change in one object requires
subsequent state changes in several others
without knowing the details of the other
objects and while avoiding tight-coupling.
Subject, Observer, ConcreteSubject,
ConcreteObserver
Applicability:
Participants:
39
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Observer Pattern Structure
40
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Observer Pattern Example
41
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Observer Pattern Example
CLASS Subject:
DEF PROTECTED TEMP-TABLE ttObserver
NO-UNDO
FIELD observer AS CLASS PROGRESS.Lang.Object.
METHOD PUBLIC VOID Attach
(INPUT observer AS CLASS Observer):
IF NOT CAN-FIND(ttObserver WHERE
ttObserver.observer = observer) THEN
DO:
CREATE ttObserver.
ttObserver.observer = observer.
END.
END METHOD.
METHOD PUBLIC VOID Detach
(INPUT observer AS CLASS Observer):
FIND FIRST ttObserver WHERE
ttObserver.observer = observer
NO-ERROR.
IF AVAILABLE ttObserver THEN
DELETE ttObserver.
END METHOD.
…
42
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Observer Pattern Example
…
METHOD PUBLIC VOID Notify():
DEFINE VAR rObserver AS CLASS Observer NO-UNDO.
FOR EACH ttObserver:
rObserver = CAST(ttObserver.observer,
Observer).
rObserver:Action(THIS-OBJECT).
END.
END METHOD.
END CLASS.
43
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Observer Pattern Example
CLASS Stock INHERITS Subject:
DEF PUBLIC PROPERTY symbol AS CHAR
NO-UNDO GET. SET.
DEF PUBLIC PROPERTY price AS DECIMAL
NO-UNDO
GET .
SET (INPUT piPrice AS DECIMAL):
price = piPrice.
Notify().
END SET.
CONSTRUCTOR PUBLIC Stock
(INPUT newSymbol AS CHAR,
INPUT newPrice AS DEC):
SUPER ().
symbol = newSymbol.
price = newprice.
END CONSTRUCTOR.
END CLASS.
44
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Observer Pattern Example
CLASS Observer:
METHOD PUBLIC VOID Action
(INPUT subject AS CLASS Subject):
/* to be overridden */
END METHOD.
END CLASS.
45
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Observer Pattern Example
CLASS Investor INHERITS Observer:
DEF PRIVATE PROPERTY name AS CHAR
NO-UNDO GET. SET.
CONSTRUCTOR PUBLIC Investor
(INPUT newName AS CHAR):
name = newName.
END CONSTRUCTOR.
METHOD PUBLIC OVERRIDE VOID Action
(INPUT subject AS Subject):
DEF VAR rStock AS CLASS Stock NO-UNDO.
rStock = CAST (subject,Stock).
MESSAGE NAME rStock:price
VIEW-AS ALERT-BOX.
END METHOD.
END CLASS.
46
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Observer Pattern Example
Main:
DO:
DEF VAR rStock
AS CLASS Stock NO-UNDO.
DEF VAR rInvestor1 AS CLASS Investor NO-UNDO.
DEF VAR rInvestor2 AS CLASS Investor NO-UNDO.
rInvestor1 = NEW Investor("J Johnson").
rInvestor2 = NEW Investor("B Blogs").
rStock = NEW Stock("PRGS", 33.00).
rStock:Attach(rInvestor1).
rStock:Attach(rInvestor2).
rStock:price = 34.00.
rStock:price = 35.00.
rStock:DETACH(rInvestor2).
rStock:price = 36.00.
rStock:Detach(rInvestor1).
rStock:price = 29.00.
END.
47
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Command Pattern
Name:
Classification:
Command
Behavioral
Motivation:
Encapsulate a request as an object enabling
the queuing and logging of requests and the
un-doing and re-doing of operations.
When support for undo and redo is required.
Applicability:
Participants:
48
Command, ConcreteCommand, Client,
Invoker, Receiver
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Command Pattern Structure
49
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Command Pattern Example
50
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Command Pattern Example
CLASS Account:
DEF VAR rCalculator AS CLASS AccountCalculator
NO-UNDO.
DEF PROTECTED TEMP-TABLE ttCommand
NO-UNDO
FIELD commandNum AS INT
FIELD command
AS CLASS PROGRESS.Lang.Object
INDEX num commandNum.
DEF PRIVATE VAR curr AS INT INIT 0 NO-UNDO.
CONSTRUCTOR PUBLIC Account():
rCalculator = NEW AccountCalculator().
END CONSTRUCTOR.
…
51
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Command Pattern Example
…
METHOD PUBLIC VOID CalcBalance
(INPUT operator AS CHA,
INPUT operand AS DECIMAL):
DEF VAR rCommand AS CLASS COMMAND NO-UNDO.
rCommand = NEW
AccountCommand(rCalculator,operator,operand).
rCommand:EXECUTE().
CREATE ttCommand.
curr = curr + 1.
ttCommand.commandNum = curr.
ttCommand.command = rCommand.
END.
…
52
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Command Pattern Example
…
METHOD PUBLIC VOID CommandRedo(INPUT levels AS
INT):
DEF VAR l AS INT NO-UNDO.
DEF VAR lastNum AS INT NO-UNDO.
DEF VAR rCommand AS CLASS COMMAND NO-UNDO.
FIND LAST ttCommand NO-ERROR.
IF AVAILABLE ttCommand THEN
lastNum = ttCommand.commandNum.
DO l = 1 TO levels:
IF curr > lastNum THEN
DO:
curr = lastNum.
LEAVE.
END.
ELSE
…
53
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Command Pattern Example
…
DO:
FIND FIRST ttCommand WHERE
ttCommand.commandNum = curr NO-ERROR.
IF AVAILABLE ttCommand THEN
DO:
rCommand = CAST
(ttCommand.command, Command).
rCommand:Execute().
curr = curr + 1.
END.
END.
END.
END METHOD.
END CLASS.
54
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Command Pattern Example
CLASS AccountCalculator:
DEFINE PRIVATE VAR curr AS DECIMAL
NO-UNDO.
INIT 0
METHOD PUBLIC VOID Operation
(INPUT operator AS CHA,
INPUT operand AS DECIMAL):
CASE operator:
WHEN '+' THEN
curr = curr
WHEN '-' THEN
curr = curr
WHEN '*' THEN
curr = curr
WHEN '/' THEN
curr = curr
END CASE.
+ operand.
- operand.
* operand.
/ operand.
MESSAGE curr operator operand VIEW-AS
ALERT-BOX.
END.
END CLASS.
55
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Command Pattern Example
CLASS Command:
METHOD PUBLIC VOID EXECUTE ():
/* to be overridden */
END METHOD.
METHOD PUBLIC VOID UnExecute ():
/* to be overridden */
END METHOD.
END CLASS.
56
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Command Pattern Example
CLASS AccountCommand
INHERITS Command:
DEF PUBLIC VAR accountCalculator AS CLASS
AccountCalculator NO-UNDO.
DEF PUBLIC PROPERTY operator
AS CHAR
NO-UNDO GET . SET .
DEF PUBLIC PROPERTY operand
AS DECIMAL
NO-UNDO GET . SET .
CONSTRUCTOR PUBLIC AccountCommand
(INPUT calc AS CLASS AccountCalculator,
INPUT opor AS CHAR,
INPUT opand AS DECIMAL ):
accountCalculator = calc.
operator
= opor.
operand
= opand.
END CONSTRUCTOR.
METHOD PUBLIC OVERRIDE VOID EXECUTE():
accountCalculator:Operation
(operator,operand).
END METHOD.
…
57
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Command Pattern Example
…
METHOD PUBLIC OVERRIDE VOID UnExecute():
DEF VAR undoOperator AS CHAR NO-UNDO.
undoOperator = GetUndo(operator).
accountCalculator:Operation
(undoOperator,operand).
END METHOD.
METHOD PRIVATE CHAR GetUndo
(INPUT operator AS char):
DEF VAR undoOperator AS CHAR NO-UNDO.
CASE operator:
WHEN '+' THEN
undoOperator = '-'.
WHEN '-' THEN
undoOperator = '+'.
WHEN '*' THEN
undoOperator = '/'.
WHEN '/' THEN
undoOperator = '*'.
OTHERWISE
undoOperator = ' '.
END CASE.
RETURN undoOperator.
END METHOD.
END CLASS.
58
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Command Pattern Example
Main:
DO:
DEF VAR rAccount AS CLASS Account NO-UNDO.
rAccount = NEW Account().
rAccount:CalcBalance("+",
rAccount:CalcBalance("-",
rAccount:CalcBalance("*",
rAccount:CalcBalance("/",
100.00).
50.00).
1.0525).
2).
rAccount:CommandUndo(3).
rAccount:CommandRedo(2).
END.
59
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Sources of Design Patterns
 Gang of Four (GoF)
 Core J2EE
 Pattern-Oriented Software Architecture (POSA)
 Patterns of Enterprise Application Architecture



60
(Fowler)
Microsoft Solution Patterns
Enterprise Integration Patterns (Hohpe & Woolf)
Microsoft Integration Patterns
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Other Relevant Design Patterns
 Enterprise Application Patterns
•
•
•
•
•
61
Data Mapper
Unit of Work
Lazy Load
Foreign Key Mapping
Inheritance Mappers
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Limitations of Design Patterns
 Not a panacea
 Not directly reuse-able unlike components
 Just another set of abstractions
 Very dependent upon situation & context
 Don’t always apply to real-world situations
 More readily implemented in some
programming languages and not others
62
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
In Summary
 Many common design problems



63
already have tried and proven
solutions
Some wheels have already
been invented
Design patterns exist in the
public domain
Design patterns can be readily
implemented in OpenEdge ABL
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
For More Information, go to…
 PSDN
• Implementing the OpenEdge Reference Architecture
with Classes
• http://www.psdn.com/library/kbcategory.jspa?catego
ryID=1212
 Progress eLearning Community
• What's New OE 10.1 Object Oriented Programming
 Documentation
• 10.1B Object-oriented Programming manual
• 10.1B New and Revised Features manual
64
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Relevant Exchange 2007Sessions
 DEV-6: Getting Started with Object-Oriented



65
Programming
DEV-12: Object-Oriented Programming in
OpenEdge ABL
DEV-20: Using Classes & Procedures in
OpenEdge 10.1B
ARCH-7: A Class-Based Implementation of the
OERA
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Questions?
66
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Thank you for
your time
67
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
68
Leveraging Design Patterns in ABL Applications
© 2007 Progress Software Corporation
Download