the Development Speed for Crosscutting Code? An Empirical Study - - PowerPoint PPT Presentation

the development speed for crosscutting code an empirical
SMART_READER_LITE
LIVE PREVIEW

the Development Speed for Crosscutting Code? An Empirical Study - - PowerPoint PPT Presentation

Does Aspect-Oriented Programming Increase the Development Speed for Crosscutting Code? An Empirical Study Stefan Hanenberg, Sebastian Kleinschmager, Manuel Josupeit-Walter University of Duisburg-Essen, 2009 Presenter: Olivier Clerc ETH Zrich


slide-1
SLIDE 1

Does Aspect-Oriented Programming Increase the Development Speed for Crosscutting Code? An Empirical Study

Stefan Hanenberg, Sebastian Kleinschmager, Manuel Josupeit-Walter University of Duisburg-Essen, 2009 Presenter: Olivier Clerc ETH Zürich

1

slide-2
SLIDE 2

Logging

void foo() { bar(); } void bar() { baz(); } void baz() { System.out.println(“Hello, world!“); }

  • Extend the program such that each method call is written to a log

2

slide-3
SLIDE 3

OOP Solution

void foo() { Logger.log("foo"); bar(); } void bar() { Logger.log("bar"); baz(); } void baz() { Logger.log("baz"); System.out.println(“Hello, world!“); }

  • Add logging instruction at beginning of each method
  • Tedious if number of methods is large
  • The logging behavior is dependent on the program

3

slide-4
SLIDE 4

Cross-cutting Concerns

  • Logging is a prime example of a cross-cutting concern
  • Definition:

A behavior that affects multiple modules in traditional OOP

4

slide-5
SLIDE 5

Aspect-Oriented Programming (AOP)

  • Programming paradigm that addresses cross-

cutting concerns

  • Separation of a software system‘s cross-

cutting concerns from its core logic

  • Aspect = a cross-cutting concern
  • Base code = the core logic (traditional OOP)
  • Program = base code + set of aspects

5

slide-6
SLIDE 6

AOP Solution

public aspect LoggerAspect { pointcut methodInvocation() : execution(* *(..)); before() : methodInvocation() { MethodSignature signature = (MethodSignature) thisJoinPoint.getSignature(); Logger.log(signature.getMethod().getName()); } }

  • Logging is represented as a new aspect
  • Completely decoupled from the rest
  • The aspect can be reused for any other OO program

Pointcut: „WHEN?“ Advice: „WHAT?“

6

slide-7
SLIDE 7

Intent of the Paper

  • Proponents of AOP claim...
  • It provides better modularization
  • It is more readable
  • It is more maintainable (suggested by another study)
  • What about the development time?
  • The paper tries to answer:

“Under what circumstances does AOP reduce the development time?“

  • Important: this question is only asked for cross-cutting

concerns

7

slide-8
SLIDE 8

Assumption of the Authors

  • Assumption:

“The more code targets a cross-cutting concern affects, the more it pays out to use AOP“

  • Rationale:

For logging only 3 methods it is easier to simply add 3 lines of code, instead of writing an aspect.

8

slide-9
SLIDE 9

Experimental Setup

  • 1 target application (small game of 9 classes)
  • 20 subjects (students with 1.5h AOP experience)
  • 9 tasks (extensions) to be implemented
  • To be done using both AOP (AspectJ) and OOP (Java)
  • Development time for a task was measured from the

first code change until all test cases pass

9

slide-10
SLIDE 10

Tasks

Task # code targets Code sim.

  • 1. Logging

110 ≠

  • 2. Parameter Null

36 ≠

  • 3. Synchronization

52

=

  • 4. Player Check

4 =

  • 5. Notify Observers

19 =

  • 6. Observers Null

15 =

  • 7. Refresh Constraint

8 ≠

  • 8. Label Value Check

6 ≠

  • 9. Level Check

7

=

10

slide-11
SLIDE 11

Variance Analysis

“What causes the different development times?“

  • The development time potentially depends on two factors:
  • the task
  • the language
  • Result of 2-factor ANOVA (analysis of variances) :
  • The task has an important effect
  • The language has an effect
  • The effect of the language depends on the task (interaction effect)

11

slide-12
SLIDE 12

Variance Analysis (2)

Effect F value p value Main effect of task 55.02 ~0 Main effect of language 13.75 0.001 Interaction effect of task and language 9.85 ~0

12

slide-13
SLIDE 13

Equality of Development Times

“For what tasks does the choice of language result in different development times?“

  • For each task there are 20 samples of the AO and OO

development time

  • A Wilcoxon test was performed to check which of the

following hypotheses hold:

  • H0: the development times for AO and OO are equal
  • H1: they are not equal

13

slide-14
SLIDE 14

Task # code targets Code sim.

  • 1. Logging

110 ≠

  • 2. Parameter Null

36 ≠

  • 3. Synchronization

52

=

  • 4. Player Check

4 =

  • 5. Notify

Observers

19 =

  • 6. Observers Null

15 =

  • 7. Refresh

Constraint

8 ≠

  • 8. Label Value

Check

6 ≠

  • 9. Level Check

7

=

All tasks as one

n/a n/a

14

slide-15
SLIDE 15

Task # code targets Code sim. All devs

  • 1. Logging

110 ≠ +

  • 2. Parameter Null

36 ≠ +

  • 3. Synchronization

52

=

  • 4. Player Check

4 =

  • 5. Notify

Observers

19 =

  • 6. Observers Null

15 =

  • 7. Refresh

Constraint

8 ≠

  • 8. Label Value

Check

6 ≠

  • 9. Level Check

7

=

  • All tasks as one

n/a n/a

  • 15
slide-16
SLIDE 16

Task # code targets Code sim. All devs Fast OO devs Slow OO devs

  • 1. Logging

110 ≠ + +

  • 2. Parameter Null

36 ≠ +

  • 3. Synchronization

52

=

  • 4. Player Check

4 =

  • 5. Notify

Observers

19 =

  • 6. Observers Null

15 =

  • 7. Refresh

Constraint

8 ≠

  • 8. Label Value

Check

6 ≠

  • 9. Level Check

7

=

  • All tasks as one

n/a n/a

  • n/a

n/a

16

slide-17
SLIDE 17

Task # code targets Code sim. All devs Fast OO devs Slow OO devs Fast AO devs Slow AO devs

  • 1. Logging

110 ≠ + + +

  • 2. Parameter Null

36 ≠ +

  • 3. Synchronization

52

=

  • 4. Player Check

4 =

  • 5. Notify

Observers

19 =

  • 6. Observers Null

15 =

  • 7. Refresh

Constraint

8 ≠

  • 8. Label Value

Check

6 ≠

  • 9. Level Check

7

=

  • All tasks as one

n/a n/a

  • n/a

n/a n/a n/a

17

slide-18
SLIDE 18

Threats to Validity

  • Authors:
  • The experiment was done in different sessions
  • Not all received exactly the same tutorial
  • Learning curve of subjects ignored
  • Are the tasks representative?
  • My opinion:
  • Are the statistics expressive? (only 20 samples)
  • Subjects were all AOP novices (only 1.5h of learning)
  • What about other AOP languages apart from AspectJ?

18

slide-19
SLIDE 19

Conclusion

“Under what circumstances does AOP reduce the development time?“

  • 1. if the developers are experienced;
  • 2. if the number of code targets is large (≥36);
  • 3. if the OOP code snippets to be inserted are different from

each other.

19

slide-20
SLIDE 20

Questions?

20