An Aspect-Aware Outline Viewer by sarahjanebelonga

VIEWS: 10 PAGES: 20

									An Aspect-Aware Outline Viewer


     Michihiro Horie and Shigeru Chiba
    Tokyo Institute of Technology, Japan


                                           1
Our purpose

   Problem: difficulty to understand relationships
    between programs and aspects
       Obliviousness: aspects and classes separately specified
       Must understand whole system to understand one class


   Solution:
       Overcome program and aspects separation in visualization
       But keep obliviousness in the code
       To ensure code/visualization consistency: need for
        automatic tools


                                                                   2
AJDT

   AJDT shows
       Join points selected by pointcuts
   For AJDT,
       AOP is an event-based programming.
       AJDT shows the locations of events.
   No modular reasoning
       Broken encapsulation
       Developers must see the internal implementation of
        a class to understand the program behavior.


                                                        3
Our solution: AspectScope

   Overcomes the limitations of AJDT
   Preserves modular reasoning
       More abstract reasoning
       Helps better understand programs




                                           4
AspectScope
   An outline viewer of a class
       Eclipse plug-in for AspectJ
       It shows the outline of a class woven with an aspect
           Modules = classes, methods and fields
           Generates javadoc comments for modules
               Document how and when aspects extend their behavior




    outline                       ここに AspectScope の図             javadoc




                                                                           5
Modular reasoning

   AspectScope enables modular reasoning
       No show of source code (the implementation of
        methods)
       Encapsulation is preserved.
       Still shows enough information to help understanding

   In AspectScope, an aspect is an extension to a class.
       AspectScope shows an extension by an aspect as part of
        “the specification of a module interface”.


                                                           6
Modular reasoning

   Concrete benefit:
       Abstracts the differences between some kinds of
        pointcuts, to simplify visualization
       Concrete example: unified representation of
        “execution pointcuts” and “call pointcuts”




                                                          7
 Execution pointcut                   visualized by AspectScope

   AspectScope indicates…
       an advice extends the behavior of a callee method.

after(): execution(void Point.setX(int)) {
   Display.update();
}




                                                                  8
    Call pointcut                  (also get & set)
   AJDT indicates..
       An advice intercepts a call in a caller method.

    after(): call(void Point.setX(int)) {
       Display.update();
    }
                                               Caller class


    AJDT Editor




                                                              9
    Call pointcut                (also get & set)
   Unlike AJDT, AspectScope indicates...
       An advice extends the behavior of a callee method.

    after(): call(void Point.setX(int)) {
       Display.update();
    }


                                           Callee
    AspectScope
                                           class




                                                             10
    Aspects as conditional extensions
   In AspectScope, aspects are module extensions
       But can be conditional: within and cflow pointcuts
       Extension only if a caller satisfies a condition
after(): call(void Point.setX(int)) && within(Line) {
   Display.update();
}
                                                     Conditional
                                                      extension




                                                              11
 javadoc comments
    Automatically generated or gathered from
     from source code of methods and advices
From the implementation
of setX()


From the pointcut
definition



 From the advice
 definition

                                                12
    Explaining pointcuts
   Interprets all AspectJ‟s pointcuts into “developer
    English”
                                      void setX(int)
pointcut move() :
   call(void Shape+.set*(int))
   || call(void Shape+.moveBy(..));


Wild cards *, + , and .. are
expanded to concrete name.


after(): move() && within(Line) {
  Display.update();
}                                                      13
  Concrete example 1: Observer aspect
 An advice is executed when a setter method is
  called.          Shape              Display
                                               *                 1
                              …                                      update()
                              …                                       …



The advice is not executed
when setX() is called             Line               Point                 Rectangle
within setP1() in Line.
                             setP1(Point p1)       setX(int x)             …
                             setP2(Point P2)       setY(int y)             …
                              …                    …                       …


pointcut change() : call(void Shape+.set*(..));
after(): change() && !cflowbelow(change()) {
    Display.update();
}                                                                                      14
AspectScope vs. AJDT
 AspectScope                 AJDT Editor




                           AJDT shows join point
                           shadow at a caller side.




               AspectScope shows how
               setP1() is extended for notifying
               an observer of updates.         15
    Concrete example 2: Logging aspect
   Print a log message just before a method in
    Canvas calls draw() in Graphics.
class Canvas {
  Image image;               aspect LoggingAspect {
     :
  void paint(Graphics g) {     before(): call(* Graphics.draw(..))
        :                            && within(Canvas) {
       g.draw(image);            System.out.println(“log”);
        :
  }                            }
   :                         }
}




                                                                 16
  AspectScope vs. AJDT
    AspectScope                                       AJDT Editor




                               AJDT shows a caller-side
                               expression.

                             before() : call(void Graphics.draw(Image))
AspectScope shows the                  && within(Canvas) {
                                System.out.println(…);
extension to a callee-side    }
method.
                                                                 17
    Related Work
   Aspect-Aware Interface [Kiczales et al. „05]
       It shares basic ideas with AspectScope.
       Conceptual framework for modular reasoning.
           This paper does not mention call, get, and set pointcuts.
           No javadoc comments.
           Not a practical development tool, unlike AspectScope.


   Classbox/J [Bergel et al. „05]
       Similar to the interpretation of aspects by AspectScope.
       Enables an extension only effective to a particular module.



                                                                        18
    Conclusion

   AspectScope:
                         A programming tool for AspectJ
       An outline viewer of a class
       It shows the outline of a class woven with an aspect
           Declared methods and fields
           javadoc comments for the methods and fields
           How and when the aspect extends their behavior


       It enables modular reasoning


                                                             19
  Intertype declaration
    AspectScope indicates appended methods and fields.

public aspect UpdateSignaling {
   Point Point.getLocation() { … }
       :
}




                                                     20

								
To top