Download presentation
Presentation is loading. Please wait.
Published byBridget Moody Modified over 9 years ago
1
Using AOP to Ease Evolution Presented by David Shepherd (QLI & UD) Co-Authors: Thomas Roper (QLI) and Lori Pollock (UD)
2
2 Making a Distributed Database Application Issue: Stale Data DB Delaware Hawaii North Carolina Request Data Data Detective DMV Update ? notify Motivation for Evolution in the Field Databases with Records Of Cars Detective App. Non-Trivial Data Mining Clerk App. Update car data
3
3 Desired Evolution Task Notification Scheme DMV AppDB Server DetectApp Interesting Update Return Results Send Primary Keys Return Results Query DB Can a database support this functionality? Who is interested in these records? No
4
4 Software Evolution Problem Open Source Software X A dditional Feature(s) 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)
5
5 Overview of Evolution Process Original Open Source Software Augmented Open Source Software Original Open Source Software Feature Augmented New Version OSS New Version OSS Feature Aug- mented New Version OSS2 New Version OSS2 Feature OOP Process AOP Process 1 1 2 2 New Version of OSS Available
6
6 Possible OOP Solution DBObserver executes notifies Notifies listeners Add Code into method Add Code into method Add methods Add interface Add implementation of interface 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(DatabaseDistributedNotifier. getInstance());... } SQLQuery notifyObservers getQuery addObserver SQLQuery addVar Clear … DbServer executeQuery openConnection parseQuery commitQuery Public interface DBObserver{ … } Public class MckoiDBObserver implements DBObserver { … } Original OSS Code New Feature Code
7
7 2 packages 3 classes *needs to be added here Crosscutting Concern (CCC) An Outcome of OOP Solution This represents one.java file Taller = Longer file Blue lines represent our feature’s implementation
8
8 Another Outcome of OOP Solution Tangling Statement level Method level
9
9 Pointcut AOP Solution ObserverProtocol SQLQuery execute Prepare SQLQuery Pointcut SubjectChange Pointcut updateObserver Pointcut registration DBObserverProtocol Pointcut subjectChange Pointcut updateObserver Pointcut registration Declare Subject Declare Observer DBObserver update Feature Implementation Original Code Base Key Feature: Only loosely coupled with Original OSS Key Feature 2: Observer concern modularized Pointcut
10
10 Finding Code Insertion Points Database Codebase A First Step in implementation (for both methods)
11
11 Finding Insertion Point – A Closer Look Statement “Select”’s 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; } Snippet from JDBCDatabaseInterface’s 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); } … Which place is better?
12
12 OOP Process – Find Insertion Point 1 Insert in most likely place 2 Test – Fail 3 Remove Code We removed an extra statement Causing two errors 4 Continue Cutting and Pasting... 5 Answer Co-Worker’s Question About Another Project Ponder, where was I? (what is my working set)
13
13 AOP Process – Find Insertion Point 1 Set Pointcut to Most Likely Place 2 Test – Fail 3 Change Pointcut 4 Continue Changing Pointcut... 5 Answer Co-Worker’s Question About Another Project Only working with one file: Easy to remember working set
14
14 New OSS Version Available Original Open Source Software Augmented Open Source Software Original Open Source Software Feature Augmented New Version OSS New Version OSS Feature Aug- mented New Version OSS2 New Version OSS2 Feature OOP Process AOP Process 2 2
15
15 OOP Solution another outcome Database Codebase Process with OOP 1.Find Feature Code 2.Extract Feature Code 3.Find new insertion points 4.Insert Feature code New Database Codebase
16
16 Evolution of Codebase: AOP Solution Database Codebase New Code Well-Modularized Separate from main code base Refers to main code base New Database Codebase AOP: At worst, realign pointcut references
17
17 Concluding 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
18
19
19 Slide graveyard
20
20 AOP Process – Find Insertion Point Snippet from JDBCDatabaseInterface’s execQuery method... … try { // Evaluate the sql query. Table result = sql_executor.execute(database_connection, query); query.notification(result); error=false; // 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
21
22
22 com.mckoicom.mckoi.database com.mckoi.database.control com.mckoi.toolscom.mckoi.utilcom.mckoi.storecom.mckoi.runtimecom.mckoi.jfccontrolscom.mckoi.debugcom.mckoi.database.sqlcom.mckoi.database.regexbridgecom.mckoi.database.procedurecom.mckoi.database.jdbcservercom.mckoi.database.jdbc com.mckoi.database.interpret com.mckoi.database.global com.mckoi com.mckoi.database com.mckoi.database.control com.mckoi.database.global com.mckoi.database.interpret com.mckoi.database.jdbc com.mckoi.database.jdbcserver com.mckoi.database.procedure com.mckoi.database.regexbridge com.mckoi.database.sql com.mckoi.debugc om.mckoi.jfccontrols com.mckoi.runtime com.mckoi.store com.mckoi.tools com.mckoi.util
23
23 Possible Solutions Can a database support this functionality? DbServer executeQuery openConnection parseQuery commitQuery … 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. 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(DatabaseDistributedNotifier. getInstance());... } SQLQuery notifyObservers getQuery addObserver removerObserver SQLQuery addVar translateObjectType clear …
24
24 Quantum Leap Innovations – Business Model What We Do We create pioneering technologies that are used by our partners to build innovative products and services. How We Do It We support our partners as a team member by providing our unique IP, software technologies and people. Gov’t AgenciesPartners Technology Differentiated Products & Services Research Programs End Users Pioneering Software Technologies Tom, am I allowed to show this? It was from the Template.ppt in J:\Presentations.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.