Title: a Delphi Framework
1a Delphi Framework
2About me
- Software Architect at Chase Cooper LTD.
- Background in Java/J2EE
- New to the Delphi world
- RemObjects, IntraWeb, DbGo.
3About 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.
4Background problem 1
DB Svr
App. Server
Web Server
DSPRV BLO DB Access
CDS
IWForm
DSPRV BLO DB Access
CDS
IWForm
DSPRV BLO DB Access
CDS
IWForm
DSPRV BLO DB Access
CDS
IWForm
- Not modular/reusable Business Logic.
- Client connection, Logic and DB access in the
same unit. - Client/DB dependency.
5Background 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.
6BackGround
- Consequences
- time on developing BL is not very optimized.
- Developers cant 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.
7Delphi 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.
8Service Level Components (I)
Web Server
App. Server
Application Business Logic
Application - GUI
Context (Service API)
Session (Service API)
Cache
Cache
Log
Persistence engine
Trn Man.
Navigator
Server connectivity
Authentication
Authorisation
eMail
User State Man. (Shopping Cart)
DB connection
9Service 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.
10Developing BL as Modular Components (I)
DB Svr
App. Server
Web Server
DSPRV BLO DB Access
CDS
IWForm
DB Svr
App. Server
Web Server
DSPRV
CDS
IWForm
BLO
ADO
11Developing 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.
12Developing 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.
13Developing BL as Modular Comps (IV)
- BLO_Order
- Insert
- Delete
- Amend
- Select
VO_Order
DAO
14Developing BL as Modular Comps (IV)
- BLO_Order
- Insert
- Delete
- Amend
- Select
VO_Order
DAO
- BLO_OrderItem
- Insert
- Delete
- Amend
- Select
VO_OrderItem
15Developing BL as Modular Comps (V)
- BLO_Order
- Insert
- Delete
- Amend
- Select
VO_Order
DAO
- BLO_OrderItem
- Insert
- Delete
- Amend
- Select
VO_OrderItem
16Developing BL as Modular Comps (V)
- Provider
- Communication with the Web tier.
- DataSnap (TDataSetProvider)
- RO service if the client uses RemObjects.
- Receives clients requests and maps them to the
proper BLOs method. - Data mapping
- Convert from Client Dependant types to DFs
internal representation. - Context object Creation/Deletion.
17The source builder Tool.
- Extracts DB schema and generates
- Value Objects
- BLO
- DataSnap components (CDS and DSPrv).
- Client Data Set.
- IW form.
18Examples
- Order System (Show prototype).
- Simple Table management.
- Check Out Shopping Cart
19Samples Simple Table Management
- Manage table ProductType.
- Create functionality
- Add, Amend, Delete Product Type.
- View Code Generated.
App. Server
Web Server
BLO
DSPrv
CDS
IWForm
Value Object
Value Object
20Samples 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
Façade User State Manager
BLO Order Items
Checkout SP
Insert
Context
Get
send message
Get Current
Shopping Cart
User State Manager
Trn Manager
Log Manager