This document discusses evolutionary problems in aspect-oriented software development. It identifies three main categories of challenges: aspect exploration, which involves discovering potential aspects in a system; aspect extraction, which involves migrating code to an aspect-oriented solution; and aspect evolution, which involves maintaining and evolving an aspect-oriented system over time. Each category presents open research problems regarding how to effectively discover, extract, and manage crosscutting concerns through the use of aspects. The document argues that addressing these problems will be important for achieving widespread adoption of aspect-oriented software development.
Evolutionary Problems In Aspect Oriented Software Development
1. Evolutionary Problems
in Aspect-Oriented
Software Development
Pr. Kim Mens
Inspired by and based on:
Dr. Tom Tourwé
K. MENS & T. TOURWE.
Evolution Issues in Aspect-Oriented Programming.
Chapter in book on quot;Software Evolutionquot;,
edited by T. Mens & S. Demeyer, pp. 197–224.
In press. Springer, 2008.
1
2. Goal
Identify some “evolution issues” in AOSD
– challenges that adopters of AO technology may face
– research problems remaining to be explored
Three main categories:
– aspect exploration : discovering potential aspects
– aspect extraction : migrating to AO solution
– aspect evolution : maintaining and evolution of AO system
Aspect
Evolution
BASE system
Aspect Aspect
LEGACY system LEGACY system
Exploration Extraction
Aspect
Aspect Aspect
2
2
3. The AOP Idea
aspect 3
aspect 1 aspect 2
Aspect
Weaver
core application functionality
woven output code
3
3
4. class Point extends Shape {
public void setX(int x) throws IllegalArgumentException {
if ( x < MIN_X || x > MAX_X )
throw new IllegalArgumentException(quot;x is out of bounds.quot;);
...
Tangled
}
with base
public void setY(int y) throws IllegalArgumentException {
if ( y < MIN_Y || y > MAX_Y )
code
throw new IllegalArgumentException(quot;y is out of bounds.quot;);
...
}
} class FigureElement extends Shape {
public void setXY(int, int) throws IllegalArgumentException {
if ( x < MIN_X || x > MAX_X )
Scattered throw new IllegalArgumentException(quot;x is out of bounds.quot;);
if ( y < MIN_Y || y > MAX_Y )
concern throw new IllegalArgumentException(quot;y is out of bounds.quot;);
...
}
}
4
4
5. aspect PointBoundsChecking {
Aspect
pointcut setX(int x):
(execution(void FigureElement.setXY(int, int)) && args(x, *))
|| (execution(void Point.setX(int)) && args(x));
before(int x): setX(x) {
if ( x < MIN_X || x > MAX_X )
class Point extends Shape {
throw new IllegalArgumentException(quot;x is out of bounds.quot;);
}
public void setX(int x) {
...
pointcut setY(int y):
}
(execution(void FigureElement.setXY(int, int)) && args(*, y))
public void setY(int y) {
|| (execution(void Point.setY(int)) && args(y));
...
}
before(int y): setY(y) {
}
if ( y < MIN_Y || y > MAX_Y )
throw new IllegalArgumentException(quot;y is out of bounds.quot;);
class FigureElement extends Shape {
}
}
public void setXY(int, int) {
...
Base code }
} 5
5
7. Aspect Exploration
Problem: how to discover potential aspect
candidates in a (legacy) system
Issues:
– how are crosscutting concerns implemented?
• taxonomy of sorts needed
– what crosscutting concerns can be discovered?
• can only trivial concerns be detected
– how do crosscutting concerns affect software quality?
• assess the need for extracting them into aspects
– how to find the crosscutting concerns in the code?
• precision / recall / coverage
7
7
10. Aspect Extraction
Problem: how to extract discovered aspect
candidates into real aspects?
Issues:
– how to separate crosscutting concerns from base code?
• depends on how tangled the code is
– how to determine appropriate joinpoints for the aspects?
• aspect languages impose limitations on kinds of joinpoints
– how to determine appropriate pointcuts for the aspects?
• prefer intensional pointcuts over extensional ones
– how to determine appropriate advice code?
• modifications required due to changing context, and due to
small variations in the scattered code 10
10
11. enclosing method, an after-advice is used instead
and describe 7 extraction transformations with the particular pointcuts they
before-advice.
ample, they define an Extract Before Call transformation, depicted in Figure
The second refactoring deals with the following c
Refactoringcode that callThehoccursoccurstowithin the execution call.method asp
Crosscuttingmoved method of before/aft
Concerns f.
a block of always before a particular In the
cut p intercepts the to that
call/block be is always
into Aspects
reintroduces the call to g at the proper execution point.
another call.
Kim Mens and Tom Tourw´
e
class A {
f
int x = 0;
void f(C c) {
class A {
x++;
int x = 0;
α (CB) this.g(); ω()
this .g();
void f(C c) {
c.h();
x++;
if (x > 0)
f
c.h();
g
x = 0;
} if (x > 0)
} x = 0;
}
}
aspect B {
aspect B {
pointcut p(A a):
pointcut p(A a):
f
execution(void A.f(C)) &&
execution(void A.f(C)) &&
g aspect
this(a) && call(void C.h());
this(a) && call(void C.h());
before(A a): p(a) { { a.g();} }
before(A a): p(a) a.g();
}
}
Figure 6. Callan
Applying Before.
Fig. 9.6: Making code aspect friendly
Making code Fig. 9.7: The Extract Before Call transformation
“extract before call”
aspect-friendly Figure 6 shows the code transformation produced
refactoring
Another alternative is to restructure the code before extracting the crosscutting concern
e, to make it fit the joinpoint model offered by the AOP language. This is the approach aspect B, the pointcut p intercepts 11
Before. In the the
en by both Binkley et al [458] and Monteiro and Fernandes [455], who suggest to apply
h that occurs within the execution of method f. 11 A
itional refactorings first in order to make the codeAlthough not explained explicitly in the paper, it is clear that applying
more “aspect friendly”. For example,
12. Aspect Evolution
Problem: how to manage the evolution of an
aspect-oriented problem?
Issues:
– how to assess the impact on the aspects when the base
system evolves?
• base system is oblivious of the aspects
– how to manage evolution of the aspects themselves?
• to make the more abstract, more reusable, less brittle, ...
– how to deal with interacting and conflicting aspects?
• two aspects can work well independently but cause problems
when combined
Aspect evolution paradox
12
12
13. Fragile Pointcut Problem
*/
*/
public class FileDownload {
public class FileDownload {
public static
import java.io.*;
public static
import java.io.*; import java.util.zip.*;
void download(String address,
void download(String address,
import java.util.zip.*;
String localFileName) {
/**
String localFileName) {
/** * Command line program to copy a file to
* Command line program to copy a file to another directory.
OutputStream
another directory. * @author Marco Schmidt
OutputStream out
* @author Marco Schmidt */
out = null;
= null;
*/ public class CopyFile {
public class CopyFile {
// constant values for
// constant values for the override option
URLConnection
URLConnection
the override option
public static final
conn = null;
public static final int int OVERWRITE_ALWAYS = 1;
conn = null;
OVERWRITE_ALWAYS = 1;
public static final
public static final int int OVERWRITE_NEVER = 2;
InputStream
OVERWRITE_NEVER = 2;
public static final
InputStream in
public static Long createChecksum(File file)
public static final int int OVERWRITE_ASK = 3;
public static Long createChecksum(File
throws IOException {
= null;
OVERWRITE_ASK = 3;
file) throws IOException {
long millis =
// program options
long millis =
System.currentTimeMillis();
// program options initialized to default values System.currentTimeMillis();
InputStream in = new
initialized to default values
private static int
InputStream in =
FileInputStream(file);
*/
private static int bufferSize = 4 * 1024; new FileInputStream(file);
bufferSize = 4 * 1024;
*/
private static boolean
public class HappyNewYear
byte[] buffer = new
private static boolean clock = true;
byte[] buffer =
public class HappyNewYear byte[bufferSize];
implements Runnable
clock = true;
private static boolean new byte[bufferSize];
private static boolean
implements Runnable copyOriginalTimestamp = true;
{
copyOriginalTimestamp = true;
private static boolean
{
private static boolean verify = true;
verify = true;
private static int
private static NumberFormat
private static int override = OVERWRITE_ASK;
private static NumberFormat formatter =
override = OVERWRITE_ASK;
formatter =
public static Long
public static Long copyFile(File srcFile, File destFile)
NumberFormat.getInstance();
copyFile(File srcFile, File destFile)
throws IOException {
throws IOException {
private JFrame frame;
InputStream in = new
InputStream in = new FileInputStream(srcFile);
FileInputStream(srcFile);
private JLabel label;
OutputStream out = new
OutputStream out = new FileOutputStream(destFile);
*/
FileOutputStream(destFile);
private long newYearMillis;
long millis =
public class FileDownload {
long millis = System.currentTimeMillis();
public static
System.currentTimeMillis();
private String message;
CRC32 checksum = null;
void download(String address,
CRC32 checksum = null;
String localFileName) {
if (verify) {
if (verify) {
public HappyNewYear(JFrame
OutputStream
checksum = new CRC32();
checksum = new
frame, JLabel label)
CRC32();
out = null;
checksum.reset();
}
{
checksum.reset();
URLConnection
byte[] buffer = new
conn = null;
byte[bufferSize];
}
// store argument GUI
byte[] buffer = new
InputStream
byte[bufferSize];
elements
int bytesRead;
while ((bytesRead =
this.frame = frame; in.read(buffer)) >= 0) {
if (verify) {
evolution
Pointcuts in program Pointcuts in evolved program
tal
den miss
i
acc int
po
join
ded e
ten aptur
n
uni int c
po
join
Class Class
Name Class Name Class
Class Attributes Name Attributes Name
Name Attributes Attributes Attributes Attributes
Attributes 1
Operations Attributes Operations Attributes
1
*
Attributes Class Class
1 Operations Operations Operations Operations
*
1 1
Operations Name Name
Operations Operations
*
Operations * Attributes Attributes
* Class Class Attributes Attributes
Name Name Operations Operations
Class
Attributes Attributes Operations Operations
Name
Attributes Attributes
Attributes
Operations Operations Class
Class Attributes
Operations Operations Name
Name Operations
Attributes
Attributes Operations
Attributes
Attributes
Operations
Source program Evolved Source program
Operations
Operations
Operations
13
13
14. Conclusion
AO is a very interesting area for software
evolution researchers to explore
– not only AOP but AOSD in general (e.g. “early aspects”)
– many open evolution problems and issues to explore
– in order to achieve widespread adoption of AOSD
– some problems can reuse existing evolution research
– other problems require dedicated solutions
– it’s not too late to jump on the train...
14
14