Title: Using AOP to Ease Evolution
1Using AOP to Ease Evolution
- Presented by David Shepherd (QLI UD)
- Co-Authors Thomas Roper (QLI) and Lori Pollock
(UD)
2Motivation for Evolution in the Field
Databases with Records Of Cars
- Making a Distributed Database Application
- Issue Stale Data
DB
DB
Data
Request Data
North Carolina
?
Detective
Request Data
notify
Delaware
DB
Data
Clerk App. Update car data
Detective App. Non-Trivial Data Mining
Update
Hawaii
DMV
3Desired Evolution Task
Who is interested in these records?
Can a database support this functionality?
DMV App
DB Server
DetectApp
Interesting Update
Send Primary Keys
Return Results
Query DB
Return Results
Database
No
4Software Evolution Problem
- Have
- Open-Source Software (OSS) App
- Need to Modify Application
- Adding Feature(s)
- Issues
- OSS evolves independently
- Injection of feature
- Maintenance of feature
- Potential Solutions
- OOP vs. Aspect-Oriented Programming (AOP)
Open Source Software X
Additional Feature(s)
5Overview of Evolution Process
New Version of OSS Available
Feature
Feature
Feature
AOP Process
Original Open Source Software
New Version OSS
New Version OSS2
2
Original Open Source Software
1
1
Aug- mented New Version OSS2
Augmented Open Source Software
Augmented New Version OSS
OOP Process
2
6Possible OOP Solution
SQLQuery
DbServer
notifyObservers getQuery addObserver SQLQuery addV
ar Clear
executeQuery openConnection parseQuery commitQuery
DBObserver
executes
Notifies listeners
notifies
Original OSS Code
Original OSS Code
New Feature Code
Add interface Add
implementation of interface
Add Code into method Add methods
Add Code into method
try // Evaluate the sql query Table
result sql_executor.
execute(db_conn, query) query.notifyObservers
(result) error false return t
public class SQLQuery implements Subject
... public void notifyObservers(Table
result) //Get the primary keys, table, etc.
ResultInfo resultInfo ... //Get query
info from the query QueryInfo queryInfo
... //update all ... public
SQLQuery() addObserver(DatabaseDistributedNo
tifier. getInstance()) ...
Public interface DBObserver
Public class MckoiDBObserver implements
DBObserver
7An Outcome of OOP Solution
2 packages
3 classes
Blue lines represent our features implementation
This represents one .java file Taller Longer
file
Crosscutting Concern (CCC)
needs to be added here
8Another Outcome of OOP Solution
- Tangling
- Statement level
- Method level
9AOP Solution
ObserverProtocol
SQLQuery
Pointcut SubjectChange Pointcut
updateObserver Pointcut registration
DBObserver
execute Prepare SQLQuery
update
Pointcut
Key Feature Only loosely coupled with Original
OSS
Pointcut
DBObserverProtocol
Pointcut
Pointcut subjectChange Pointcut
updateObserver Pointcut registration Declare
Subject Declare Observer
Key Feature 2 Observer concern modularized
Original CodeBase
Feature Implementation
10Finding Code Insertion Points
A First Step in implementation (for both methods)
Database Codebase
11Finding Insertion Point A Closer Look
Statement Selects evaluate method /
Evaluates the select statement with the given
Database context. / public Table evaluate()
throws DatabaseException
DatabaseQueryContext context new
DatabaseQueryContext(database) // Check the
permissions for this user to select from the
tables in the // given plan.
checkUserSelectPermissions(context, user,
plan) boolean error true try
Table t plan.evaluate(context) error
false return t
Which place is better?
Snippet from JDBCDatabaseInterfaces execQuery
method . . . try // Evaluate
the sql query. Table result
sql_executor.execute(database_connection,
query) // Put the result in
the result cache... This will lock this object
// until it is removed from the result set
cache. Returns an id that // uniquely
identifies this result set in future
communication. // NOTE This locks the
roots of the table so that its contents //
may not be altered. result_set_info new
ResultSetInfo(query, result) result_id
addResultSet(result_set_info)
12OOP Process Find Insertion Point
1
Insert in most likely place
2
Test Fail
3
Remove Code
4
Continue Cutting and Pasting . . .
5
Answer Co-Workers Question About Another Project
We removed an extra statement
Ponder, where was I? (what is my working set)
Causing two errors
13AOP Process Find Insertion Point
Change Pointcut
1
Set Pointcut to Most Likely Place
2
Test Fail
3
4
Continue Changing Pointcut . . .
5
Answer Co-Workers Question About Another Project
Only working with one file Easy to remember
working set
14New OSS Version Available
Feature
Feature
Feature
AOP Process
Original Open Source Software
New Version OSS
New Version OSS2
2
Original Open Source Software
Aug- mented New Version OSS2
Augmented Open Source Software
Augmented New Version OSS
OOP Process
2
15OOP Solution another outcome
- Find Feature Code
- Extract Feature Code
- Find new insertion points
- Insert Feature code
Database Codebase
New Database Codebase
16Evolution of Codebase AOP Solution
AOP At worst, realign pointcut references
- New Code Well-Modularized
- Separate from main code base
- Refers to main code base
Database Codebase
New Database Codebase
17Concluding Remarks - Lessons Learned
- AOP saves effort when adapting an open-source
project - Eases Initial Maintenance Task - Add New Feature
- Non-Invasive Change
- Maintaining Working Set
- Eases Evolution - Adapt to OSS Change
- Finding the Feature
- Only Re-Align Pointcuts
- Status
- Working Implementation
- Continue to use in ongoing industry research
AOP is AOK!
18(No Transcript)
19Slide graveyard
20AOP Process Find Insertion Point
Snippet from JDBCDatabaseInterfaces execQuery
method . . . try // Evaluate
the sql query. Table result
sql_executor.execute(database_connection, query)
query.notification(result)
errorfalse // Put the result in the
result cache... This will lock this object
// until it is removed from the result set cache.
Returns an id that // uniquely identifies
this result set in future communication. //
NOTE This locks the roots of the table so that
its contents // may not be altered.
result_set_info new ResultSetInfo(query,
result) result_id addResultSet(result_set
_info)
21(No Transcript)
22 com.mckoicom.mckoi.database
com.mckoi.database.control
com.mckoi.toolscom.mckoi.util
com.mckoi.store
com.mckoi.runtime
com.mckoi.jfccontrols
com.mckoi.debug
com.mckoi.database.sql
com.mckoi.database.regexbridge
com.mckoi.database.procedure
com.mckoi.database.jdbcserver
com.mckoi.database.jdbc
com.mckoi.database.interpret
com.mckoi.database.global
com.mckoi com.mckoi.database com.mckoi.database.co
ntrol com.mckoi.database.global com.mckoi.database
.interpret com.mckoi.database.jdbc com.mckoi.datab
ase.jdbcserver com.mckoi.database.procedure com.mc
koi.database.regexbridge com.mckoi.database.sql co
m.mckoi.debugc om.mckoi.jfccontrols com.mckoi.runt
ime com.mckoi.store com.mckoi.tools com.mckoi.util
23Possible Solutions
Can a database support this functionality?
public class SQLQuery implements Subject
... public void notifyObservers(Table
result) //Get the primary keys, table, etc.
from results ResultInfo resultInfo ...
//Get query info from the query QueryInfo
queryInfo ... for(Iterator e
observers.iterator() e.hasNext() )
((DBObserver)e.next()).
update(resultInfo,queryInfo)
public SQLQuery() addObserver(DatabaseDi
stributedNotifier. getInstance())
...
SQLQuery
notifyObservers getQuery addObserver removerObserv
er SQLQuery addVar translateObjectType clear
try // Evaluate the sql query Table
result sql_executor.execute(db_conn,
query) query.notifyObservers(result)
error false return t
DbServer
executeQuery openConnection parseQuery commitQuery
24Quantum Leap Innovations Business Model
Technology Differentiated Products Services
Pioneering Software Technologies
Research Programs
Govt Agencies
Partners
End Users
We create pioneering technologies that are used
by our partners to build innovative products and
services.
We support our partners as a team member by
providing our unique IP, software technologies
and people.
Tom, am I allowed to show this? It was from the
Template.ppt in J\Presentations.