200 likes | 413 Views
a Delphi Framework. Isaac Prado. About me. Software Architect at Chase Cooper LTD . Background in Java/J2EE: New to the Delphi world: RemObjects, IntraWeb, DbGo. About the presentation. Share our Experience. DF Background. The DF Business Logic as Modular Components
E N D
a Delphi Framework Isaac Prado
About me • Software Architect at Chase Cooper LTD. • Background in Java/J2EE: • New to the Delphi world: • RemObjects, IntraWeb, DbGo.
About the presentation Share 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.
Background: problem #1 • Not modular/reusable Business Logic. • Client connection, Logic and DB access in the same unit. • Client/DB dependency. 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
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.
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.
Delphi Framework • Main Goal: • 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.
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 eMail User State Man. (Shopping Cart) DB connection
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.
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
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.
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.
Developing BL as Modular Comps (IV) • Business Logic Object • BLO_Order • Insert • Delete • Amend • Select VO_Order DAO
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
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
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.
The source builder Tool. • Extracts DB schema and generates: • Value Objects • BLO • DataSnap components (CDS and DSPrv). • Client Data Set. • IW form.
Examples • Order System: (Show prototype). • Simple Table management. • Check Out Shopping Cart
Samples: Simple Table Management • Manage table “ProductType”. • Create functionality: • Add, Amend, Delete Product Type. • View Code Generated. Web Server App. Server IWForm CDS DSPrv BLO Value Object Value Object
Samples: Check Out Shopping Cart • Check Out Items in shopping Cart. • Create new entry in “orders” table. • For each Shopping cart item, create a “OrderItems” entry. • Send a confirmation email 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