A Delphi Framework Isaac Prado.

1 a Delphi Framework Isaac Prado ...
Author: Adela Greene
0 downloads 2 Views

1 a Delphi Framework Isaac Prado

2 About me Software Architect at Chase Cooper LTD.Background in Java/J2EE: New to the Delphi world: RemObjects, IntraWeb, DbGo.

3 About the presentationShare our Experience. DF Background. The DF Business Logic as Modular Components Service components. The source builder. Samples: Simple table management (Add/Amend/Delete). Advanced sample: Check Out Shopping Cart.

4 Background: problem #1 Not modular/reusable Business Logic.DB Svr Web Server App. Server IWForm CDS DSPRV + BLO + DB Access IWForm CDS DSPRV + BLO + DB Access IWForm CDS DSPRV + BLO + DB Access IWForm CDS DSPRV + BLO + DB Access Not modular/reusable Business Logic. Client connection, Logic and DB access in the same unit. Client/DB dependency.

5 Background: problem #2 No service components.No base components to provide with non functional services: Security. State Management. DB connectivity Scalability … No clear distinction between code implementing functional and non-functional requirements.

6 BackGround: Consequences:% time on developing BL is not very optimized. Developers can’t reuse functionality. Too much time on technical issues. After several months of development: Spaghetti code. Duplicated code (duplicated bugs). Expensive to maintain. New requirements expensive to achieve: For example: Different DB vendor.

7 Delphi Framework Main Goal: Service Level Components:Allow developers to concentrate in business logic development. Build robust, scalable and maintainable Delphi applications. Service Level Components: Persistence Engine, transaction, security, session management, shopping cart management etc…. Developers can use these services directly. Develop BL as modular components: Guidelines for implementing business logic as modular and reusable components.

8 Service Level Components (I)Web Server App. Server Application - GUI Application – Business Logic Session (Service API) Context (Service API) Cache Navigator Cache Log Persistence engine Trn Man. Server connectivity Authentication Authorisation User State Man. (Shopping Cart) DB connection

9 Service Level Components (II)Context: One instance per each thread (user request). Provides access to service components. Keeps connection to DB and Transactional Status. Persistence Engine: DAO implementation. Generates and executes SQL statements. Current implementations for SQLServer2000 and Oracle 9i. Trn. Manager. Coordinates execution of commands on Service components with DB transaction status.

10 Developing BL as Modular Components (I)Old Approach DB Svr Web Server App. Server IWForm CDS DSPRV + BLO + DB Access New Approach DB Svr Web Server App. Server IWForm CDS DSPRV BLO ADO

11 Developing BL as Modular Comps (II)DAO: Interface to the Persistence Engine. Responsible for accessing to the DB. Generates and executes SQL statements. Performs basic SQL operations as insert, delete, amend and select. Provides with DB Independency. Uses Value Objects : A V.O. encapsulates a table or view of the DB.

12 Developing BL as Modular Comps (III)Business Logic Object Implement the business rules of the system Accesses DAOs to perform operations on the DB and other BLOs to reuse their functionality. Must be reusable: Paramenters/return values must be client-independent. Note: mdf uses internal data type wrappers… Each Value Object (encapsulating a table/View) has its own BLO. Each BLO contains the basic operations: Insert, Update, Delete and Select.

13 Developing BL as Modular Comps (IV)Business Logic Object BLO_Order Insert Delete Amend Select VO_Order DAO

14 Developing BL as Modular Comps (IV)Business Logic Object BLO_Order Insert Delete Amend Select VO_Order DAO BLO_OrderItem Insert Delete Amend Select VO_OrderItem

15 Developing BL as Modular Comps (V)Business Logic Object BLO_Order Insert Delete Amend Select VO_Order DAO FACADE_Order CheckOut BLO_OrderItem Insert Delete Amend Select VO_OrderItem

16 Developing BL as Modular Comps (V)Provider: Communication with the Web tier. DataSnap (TDataSetProvider): RO service: if the client uses RemObjects. Receives client’s requests and maps them to the proper BLO’s method. Data mapping: Convert from Client Dependant types to DF’s internal representation. Context object Creation/Deletion.

17 The source builder Tool.Extracts DB schema and generates: Value Objects BLO DataSnap components (CDS and DSPrv). Client Data Set. IW form.

18 Examples Order System: (Show prototype). Simple Table management.Check Out Shopping Cart

19 Samples: Simple Table ManagementManage table “ProductType”. Create functionality: Add, Amend, Delete Product Type. View Code Generated. Web Server App. Server IWForm CDS DSPrv BLO Value Object Value Object

20 Samples: Check Out Shopping CartCheck Out Items in shopping Cart. Create new entry in “orders” table. For each Shopping cart item, create a “OrderItems” entry. Send a confirmation and delete shopping cart. App. Server BLO Orders Insert RO PRV Checkout SP Façade User State Manager Insert BLO Order Items Context Get send message Get Current Shopping Cart User State Manager Trn Manager Log Manager