arch-03: implementing the openedge™ reference architecture – part 1 john sadd progress fellow...
Post on 30-Dec-2015
230 Views
Preview:
TRANSCRIPT
ARCH-03: ARCH-03: Implementing the Implementing the OpenEdge™ Reference OpenEdge™ Reference Architecture – Part 1Architecture – Part 1
John Sadd Progress Fellow and OpenEdge Evangelist
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation2 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
AgendaAgenda
Introducing the Sample Implementation Business Entities and Data Access
Objects Business Logic Issues Conclusions
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation3 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Separated presentationand integration layers
Data accessabstracted from
storage
Common business logic with
advanced models
OpenEdge Reference Architecture – a layered view
Users Users
Presentation Layer
Business Servicing Layer
Data Access Layer
Managed Data StoresManaged
Data StoresUnmanaged Data Stores
Unmanaged Data Stores
Enterprise Services
Enterprise Services
Integration Layer
Modern Application ArchitectureModern Application Architecture
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation4 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
What are the Objectives of the What are the Objectives of the Sample Implementation?Sample Implementation?
To provide an understanding of the OpenEdge Reference Architecture by describing a sample implementation
To help you understand best practices for using OpenEdge features
To motivate architects & lead developers to think about applying the Architecture to their own projects
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation5 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
What Are Non-goals?What Are Non-goals?
Not a new framework Not intended to be comprehensive or to
cover all application use cases Not intended to be commercialized Not intended to be used without changes,
extensions, and understanding
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation6 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
How Should I Use the How Should I Use the Sample Implementation?Sample Implementation?
Use it to learn Architecture concepts more deeply
Use it to learn how best to use Progress 4GL constructs and other features
Consider it as a potential useful starting point for OpenEdge 10 application development
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation7 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
What Resources are Available?What Resources are Available?- White Papers and Example Code- White Papers and Example Code
1. Introduction
2. Business Entities and Data Access Objects
3. The Service Interface Layer
4. Using Advanced ProDataSet Language Features
5. Using an Unmanaged Data Store
6. Building a .NET™ Interface to Business Entities
7. Advanced Business Logic Issues
8. Context Management
9. Building a WebSpeed® User Interface
10. …
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation8 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
What is in the Sample Implementation What is in the Sample Implementation Code Base?Code Base?
Templates directory– Template procedures for BE’s, DAO’s etc.
Support directory– Supporting supers & other procedures
Samples directory– Code samples from the papers
– These use sports2000 but there is nothing database-specific about any sample code
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation9 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Where Do I Find It?Where Do I Find It?
The white papers and sample code are on the PSDN website at:– psdn.progress.com/library/product_info/
oera/index.ssp There will be ongoing updates Later material will describe best practices
for using OpenEdge 10.1 and its OO4GL features
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation10 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation11 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
AgendaAgenda
Introducing the Sample Implementation Business Entities and Data Access
Objects Business Logic Issues Conclusions
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation12 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
The Business Entity and Data Access The Business Entity and Data Access Object in the ArchitectureObject in the Architecture
Users Users
Business Servicing Layer
Data Access Layer
Managed Data StoresManaged
Data StoresUnmanaged Data Stores
Unmanaged Data Stores
Enterprise Services
Enterprise Services
Integration Layer
Business Entity
Data Access Object
Presentation Layer
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation13 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
The Business EntityThe Business Entity Manages the logical, internal view of application data
– Provides data to the UI and other integration layers
– Contains business logic Data is best represented as ProDataSets and their
temp-tables The Business Entity is the core value of building
applications in OpenEdge
Business
Entity
Data Access
Object DBUI API API
logical physical
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation14 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
The Data Access ObjectThe Data Access Object
Manages the physical data store– Understands the schema or other description
of the physical data– Maps between this and the logical view
All references to the physical data store should be confined to the Data Access Object
Business
Entity
Data Access
Object DBUI API API
logical physical
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation15 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
ProDataSet
The ProDataSet as a Building BlockThe ProDataSet as a Building Block
Data-Relation1
CustomerTT
1 Lift Line Skiing2 Urpon Frisbee3 Hoops Croquet
OrderTT
6 1 01/05/9336 1 01/19/9379 1 02/10/93
Database
Customer
Lift Line SkiingUrpon FrisbeeHoops Croquet
Order
1 53 01/01/932 81 01/04/933 66 01/04/93
Event LogicDataset:Before-fillBuffer:Before-fillBefore-row-fillRow-AddRow-Delete…
Data-Source1Field Map
CustNumNameContact
Data-Source2Field Map
OrderNumCustNum
OrderDate
Query…Q1 forCustomer
Query…Q2 forOrder
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation16 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Constructing the Objects –Constructing the Objects –Temp-table DefinitionsTemp-table Definitions
Define temp-tables for logical data definitions– Each temp-table in its own include file
DEFINE TEMP-TABLE eOrder
FIELD OrderNum…
DEFINE TEMP-TABLE eOrderLine
FIELD OrderNum…
FIELD LineNum…
etOrder.i
etOrderLine.i
Separate physical from logical data definitions
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation17 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Guidelines for Temp-table DefinitionsGuidelines for Temp-table Definitions
Prefix table name with e – For example
eCustomer Prefix include files with et
– etCustomer.i Rename fields for
consistency or comprehensibility
Remove unwanted:– Fields– Indexes
Add other joined DB fields Add calculated fields that
might be required for ease of use
Add BEFORE-TABLE to end of definition when tracking changes
Don’t use LIKE syntax– Temp-table LIKE
database-table– Field LIKE database-
field
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation18 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
TEMP-DB Maintenance Tool (10.0B)TEMP-DB Maintenance Tool (10.0B)
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation19 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Constructing the Objects –Constructing the Objects –Data-source ObjectsData-source Objects
Build Data-Source object procedure– Each maps a temp-table to its physical
data
etOrder.i
etOrderLine.i
DEFINE DATA-SOURCE srcOrder
FOR QUERY qOrder.
ATTACH-DATA-SOURCE()
DEFINE DATA-SOURCE srcOrderLine
FOR BUFFER OrderLine.
ATTACH-DATA-SOURCE()
sceOrder.p
sceOrderLine.p
Application Database
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation20 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Constructing the Objects –Constructing the Objects –ProDataSet DefinitionsProDataSet Definitions
Define ProDataSets for sets of related data– Each is the basis for a Business Entity
DEFINE DATASET dsOrder
FOR eOrder, eOrderline…
etOrder.i
etOrderLine.i
dsOrder.i
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation21 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Constructing the Objects –Constructing the Objects –Data Access ObjectData Access Object
Build Data Access Object for the DataSet– Manages all the Data-Source objects
daOrder.p
sceOrderLine.p
dsOrder.i
sceOrder.p
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation22 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
All the Data Access All the Data Access Components TogetherComponents Together
ApplicationDatabase
daSupport.p
initDataSources:
SUPER
SUPER
SUPER
daOrderValidate.p(optional)eOrderLineModifyBeginTrans:
sceOrder.pDEF DATA-SOURCEATTACH-DATA-SOURCERowFill handler
sceOrderLine.pDEF DATA-SOURCEATTACH-DATA-SOURCE
sceItem.pDEF DATA-SOURCEATTACH-DATA-SOURCE
daOrder.p
{dsOrder.i}{daEntity.i}
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation23 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Constructing the Objects –Constructing the Objects –Business EntitiesBusiness Entities
Build a Business Entity for each ProDataSet– Manages business logic on the logical data
– Defines the API for access from other objects
DEFINE DATASET dsOrder
FOR eOrder, eOrderline…
BusinessLogic:
END PROCEDURE.
etOrder.i
etOrderLine.i
dsOrder.i
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation24 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Business Entity Business Entity Components TogetherComponents Together
beOrder.p
{dsOrder.i}{beEntity.i}
beEntity.i
RUN daOrder.p
dsOrder.i
{etOrder.i} {etOrderLine.i} {etItem.i}
DEFINE DATASET…
beOrderValidate.p(optional)
eOrderLineModifyPreTrans:
beSupport.p
fetchCustomsaveChanges
SUPER
SUPER
Data Access Object
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation25 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
AgendaAgenda
Introducing the Sample Implementation Business Entities and Data Access
Objects Business Logic Issues Conclusions
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation26 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Business Entity Logic IssuesBusiness Entity Logic Issues
How strictly do I adhere to logic separation– Do I use an API call just for a CAN-FIND?
– Do I defer that to a database trigger? How much standard behavior should be
automated by “magic”? How do I adjust logic to allow for re-use of tables
in other ProDataSets? When do I use static versus dynamic table and
ProDataSet references?
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation27 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Accessing other Entities Accessing other Entities Through their APIsThrough their APIs
Avoid direct database access to other tables from your Business Entities
FIND eOrder WHERE eOrder.OrderNum = eOrderLine.OrderNum {&NoError}.
hCustomer = SIfindRow("Customer", "eCustomer", "CustNum", STRING(eOrder.CustNum)) .
IF hCustomer:BUFFER-FIELD("Discount"):BUFFER-VALUE < .35 THEN
DO:
ASSIGN BUFFER eOrderLine:ERROR = YES
BUFFER eOrderLine:ERROR-STRING =
"Line " + STRING(eOrderLine.LineNum) +
": Changes not allowed … ".
RETURN.
END.
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation28 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Standard “Magic” BehaviorStandard “Magic” Behavior
PROCEDURE initDataSources :
IF LOOKUP(phDataSet:NAME + "BeforeFill", cEntries) NE 0 THEN
phDataSet:SET-CALLBACK-PROCEDURE
("BEFORE-FILL", phDataSet:NAME + "BeforeFill",
TARGET-PROCEDURE).
IF LOOKUP(phDataSet:NAME + "AfterFill", cEntries) NE 0 THEN
phDataSet:SET-CALLBACK-PROCEDURE
("AFTER-FILL", phDataSet:NAME + "AfterFill",
TARGET-PROCEDURE).
Callback procedures set up through a naming convention
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation29 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Organizing Logic for Organizing Logic for Maximum Re-useMaximum Re-use
Logic that references more than one table in the ProDataSet– This should go into the Data Access Object itself
PROCEDURE eOrderLineAfterFill:
DEFINE INPUT PARAMETER DATASET FOR dsOrder.
DEFINE VARIABLE dTotal AS DECIMAL NO-UNDO.
FOR EACH OrderLine WHERE OrderLine.OrderNum =
eOrder.OrderNum:
dTotal = dTotal + OrderLine.ExtendedPrice.
END.
eOrder.OrderTotal = dTotal.
END PROCEDURE.
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation30 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Static Versus Dynamic CodeStatic Versus Dynamic Code
PROCEDURE eItemAfterRowFill:
DEFINE INPUT PARAMETER DATASET-HANDLE phDataSet.
….
hItemName = phDataSet:GET-BUFFER-HANDLE("eItem"):BUFFER-FIELD("ItemName").
DO iType = 1 TO NUM-ENTRIES(cItemTypes):
cType = ENTRY(iType, cItemTypes).
IF INDEX(hItemName:STRING-VALUE, cType) NE 0 THEN
hItemName:BUFFER-VALUE =
REPLACE(hItemName:BUFFER-VALUE, cType, cType).
END.
END PROCEDURE.
Dynamic table reference allows reuse
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation31 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
AgendaAgenda
Introducing the OpenEdge Reference Architecture Implementation
Business Entities and Data Access Objects
Business Logic Issues Conclusions
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation32 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
In SummaryIn Summary
View the sample implementation materials as a basis for discussion and learning
Use parts that are useful Extend or replace for your own purposes Expect it continue to grow and change Don’t expect it to be completed or formally
supported
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation33 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Questions?Questions?
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation34 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
Thank you for Thank you for your time!your time!
Sim
plify
you
r bu
sin
ess
Sim
plify
you
r bu
sin
ess
© 2005 Progress Software Corporation35 ARCH-03 – Implementing the OpenEdge Reference Architecture – Part 1
top related