Title: Building Robust Applications in a Database Centric Way
1Building Robust Applications in a Database
Centric Way
- Prepare yourself for J2EEs successor
Toon Koppelaars Centraal Boekhuis Netherlands
2Requirement
- Hi, I need to build a web application.
- The data must be in Oracle.
- How do I do that?
Ask n people You will get at least n answers
3I have an answer too
4Agenda
- Technology explosion
- Window-on-data applications
- Application code model
- Three layers of code
- Positioning technology explosion
- Demo
- Other resources
- A first JDeveloper Project, OOW-2002
- A Database Centric Approach to J2EE Application
Development, ODTUG-2004 - http//odtug2.fatcity.com/desktop2005/
- http//web.inter.nl.net/users/T.Koppelaars
5Technology Explosion
- Javascript
- JDBC
- Javaserver Pages
- iBATIS
- Xquery
- Spring
- PHP
- APEX (html-DB)
- ADF-BC
- Webforms
- Html/XML
- Ajax
- Struts
- Hivemind
- Ruby on Rails
- .Net
- AspectJ
- Cocoon2
- Webwork
- Javaserver Faces
- Java
- EJB
- Tapestry
- Toplink
- Hibernate
- LINQ
- Maverick
- UIX
- Wicket
- JHeadstart
Latest new kids on the block
6Observations
- This landscape has not stabilized
- New technology enters every x months
- Relatively new technology disappears
- Existing technology gets overhauled
- Speed too high for normal mortals
- Impossible to keep up
- Would require continuous training, piloting and
testing of new technology - No one developer can do all anymore
- In great contrast to the steady evolvement of SQL
and PL/SQL
7Robust Technology
- Think twice before burying lots of application
logic in these volatile technologies - Will be very costly to maintain
- TCO of application
- Use robust technology for that
- Robust technology
- Preferably outlives your application
- Evolves with surrounding IT trends
- Not overhauls, not disappears
8DBMS Technology
- SQL and PL/SQL are robust
- are future-proof - evolve
- are performant - are 24-by-7
- are secure - are monitorable
- are maintenable - are hot deployable
- are tuneable - scale
- are upwards compatible
9SQL and PL/SQL
Have become an extremely rich programming
environment
- Native dynamic SQL / User defined types / Object
Tables / Temporary Tables / Associative Arrays /
Inline views / Pipelined table functions /
Autonomous transactions / Case insensitive search
/ Regular expressions / File I/O / TCP (Mail,
http, ftp) / Webservices / XML (Transformation,
Validation, Xpath, Xquery) / LOBs - Keeps evolving with new IT trends out there
10And what about our customers?
11Our Users Still Want the Same
- Window-on-data (WoD) application
Computer, what is the status?
Data
User
window
12Application Code Model for WoD Applications
Three layers
Paint UI and respond to UI events
User Interface
Retrieval and manipulation of data
Business Logic (BL)
Data model including all integrity rules
Data Logic (DL)
13This is the Issue
- Do not build applications such that you can
easily switch your DBMS - Business logic (BL) ends up in volatile
technology - Instead,
- Build applications such that you can easily
switch front-end technology - Put BL and DL in robust technology
14Application Code Model
Three layers
Paint UI and respond to UI events
User Interface
Retrieval and manipulation of data
Business Logic (BL)
Data model including all integrity rules
Data Logic (DL)
15Suddenly All Is Simple
- All new technology UI-technology
- J2EE UI-technology
- .Net UI-technology
- Html-DB UI-technology
- OracleForms UI-technology
-
- X, where x?DBMS, UI-technology
- Technology to create windows-on-data
Do not write any BL or DL code in
UI-technology, for this code will turn out to be
very expensive to maintain
16Create Separate UI Service Objects
API calls
UI Tier
Design by Contract
You will need to architect this. Architect must
be DBMS expert and be willing/capable to learn
the du-jour technology. Then make sure the
external specialists abide by this contract.
Tailor Made UI Service Objects
BL
Your Business Logic
DBMS Tier
Your Data Model
DL
Your Integrity Rules
Only UI objects change when du-jour changes
17Demo Time
- Example
- Data model
- With data integrity rules
- Implementation with homegrown RuleGen framework
- Transaction
- Two UI service object approaches
- SQL
- PL/SQL
- Report
- Taking DB-centric approach to the extreme
18Example EMP-DEPT
Employee works for Department Department is
managed by Employee
EMP
DEPT
- At most one president allowed
- A department that employs the president or a
manager should also employ an administrator - You cannot manage more than two departments
- Department manager cannot be administrator or
president - Department manager must work for a department
he/she manages
DL
19Demo Data Logic
20Example Transaction
- Insert a new department including the department
manager - Also insert an ADMINISTRATOR, if the department
manager is a MANAGER - UI service object accepts values for
- Dept(deptno,dname,loc,mgr)
- Emp(empno,ename,job,born,hired,msal,deptno)
- Emp(empno,ename,job,born,hired,msal,deptno)
sequence
sequence
sequence
21UI Service Object View
Insert through this view
API calls
UI Tier
View V_NEW_DEPT (63)
Instead of insert trigger X_new_dept package
BL
DBMS Tier
DEPT table
DL
Rules declarative RuleGen
22UI Service Object View
Show the code
23UI Service Object Stored Procedure
Call this stored procedure
API calls
UI Tier
Procedure P_INSERT_NEW_DEPT_XML (63)
BL
X_new_dept package
DBMS Tier
DEPT table
DL
Rules declarative RuleGen
24UI Service Object Stored Procedure
Show the code
ltnew_deptgt
ltdnamegtAccountinglt/dnamegt
ltlocgtNYlt/locgt
ltename_mgrgtBrizzilt/ename_mgrgt
ltjob_mgrgtTRAINERlt/job_mgrgt
ltborn_mgrgt01-JAN-1965lt/born_mgrgt
ltmsal_mgrgt9600lt/msal_mgrgt
ltename_admin/gt
ltborn_admin/gt
ltmsal_admin/gt lt/new_deptgt
25Example Query
- Perform ad-hoc query on table EMP or DEPT
- Syntax
- Select from ltsearch criteriongt
- emp
- dept
- Emp where jobmanager
26UI Service Object Stored Procedure View
Call procedure with search criterium then select
from view
API calls
UI Tier
Procedure P_ADHOC_QUERY_CTX View V_ADHOC_QUERY
BL
Context Pipelined table function
DBMS Tier
DL
DEPT or EMP table
27UI Service Object Stored Procedure
Show the code Demo in ApEx too
28Conclusions
- Implement all BL DL down in the database
- Key succesfactor in current state of industry
- Ensure UI technology is replacable!
- Not DBMS technology
- Oracle SQL and PL/SQL are future proof
- Let DBMS do all but UI
- Separate business logic from data logic
- Separate UI service objects from business logic
- J2EE, the current hype is it future proof?
- I dont know dont care
- I do not fear its successor
29Questions Answers
Building Robust Applications in aDatabase
Centric Way
Prepare yourself for J2EEs successor
Toon Koppelaars t.koppelaars_at_inter.nl.net t.koppel
aars_at_centraal.boekhuis.nl http//web.inter.nl.net/
users/T.Koppelaars
Thank you for your attention
30(No Transcript)