Comparing Three Aspect Mining Techniques

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Event

    Comparing Three Aspect Mining Techniques - Presentation Transcript

    1. Comparing Three Aspect Mining Techniques Fernando Sérgio Barbosa Faculdade de Engenharia da Universidade do Porto
    2. Agenda
      • Introduction
      • The three aspect mining techniques
        • Fan In Analysis
        • Dynamic Analysis
        • Clone Detection
      • The experiment
      • Comparing the techniques
      • Conclusion
    3. Introduction
      • Software Systems have concerns that are spread over many modules
        • These are called crosscutting concerns
        • Typical ones are Logging, Security, Memory management, etc
      • Aspect Oriented Programming helps to modularise those crosscutting concerns placing them inside aspects
    4. Introduction
      • Refactoring the system to an AOP system is therefore a good decision
      • How do we identify crosscutting concerns?
        • Typical ones are easy to identify
          • but they are only a few
        • We can inspect the code and do it manually
          • But this is feasible only in small systems
        • With the help of tools
    5. Introduction
      • Aspect Mining
        • Searching the code for crosscutting concerns that may be converted to aspects
        • It is a very important task in system refactoring
        • There are many aspect mining techniques
        • We need to know how the various techniques compare in order to use them wisely
    6. Introduction
      • We will compare 3 aspect mining techniques:
        • Fan In Analysis
        • Dynamic Analysis
        • Clone Detection
      • The comparison will be qualitative
      • We aim to find:
        • Techniques strengths
        • Techniques weaknesses
        • Techniques combination possibilities
    7. Fan In Analysis
      • The Fan In Metric of a method can be defined as:
      • Polymorphism affects this metric:
        • A call to a method contributes to the Fan In of the same method of subclasses and superclasses
      • The more places the method is called from the more likely it is that the method implements a crosscutting concern
      The number of distinct method bodies that can invoke the method
    8. Dynamic Analysis
      • Dynamic Analysis uses Formal Concept Analysis
      A concept groups all objects that share the same properties and such that no other objects have those properties nor are there any other properties they have in common
    9. Dynamic Analysis
      • In Dynamic Analysis objects are the traces obtained using the application
        • to obtain the traces some use cases are run
      • The properties are the methods called during the traces
      • When one concept has only one object (one use case) the properties are the methods associated with that use case
        • These are the specific concepts
      • Concepts that include several use cases are generic concepts
    10. Dynamic Analysis
      • Example
      Use-case X BinaryTreeNode.search(java.lang.Comparable) X BinaryTreeNode.insert(BinaryTreeNode) X BinaryTreeNode.BinaryTreeNode(java.lang.Comparable) X BinaryTree.search(java.lang.Comparable) X BinaryTree.insert(BinaryTreeNode) X X BinaryTree.BinaryTree() Search Insert Method
    11. Dynamic Analysis
      • A concept is a candidate aspect if:
        • (scattering) More than one class contributes to the functionality associated with the given concept
        • (tangling) The class itself addresses more than one concern – appears in more than one use case concept
    12. Clone Detection
      • Clone Detection techniques try to find duplicated code which may have been adapted from the original
      • There are two likely causes for clone code occurrences in crosscutting concerns:
        • Scattered code is not well modularised so developers are unable to reuse it and are forced to write the same code over and over
        • They may use particular code conventions to implement superimposed functionality
    13. The Experiment
      • The target of the experience was the JHotDraw framework
      • This framework is a Java GUI framework for technical and structured graphics
      • It was developed as a design exercise to demonstrate the use of the GOF patterns
      • It is a well known and well designed framework used as a test case in several aspect mining papers
    14. The Experiment with Fan In
      • The setting up of the Fan In experiment is quite easy
        • All that is needed is to create a project in Eclipse
      • The results are fast to obtain
      • The result, with all filters on, was 479 methods
      • With a threshold of 10 in the Fan In metric the total number of methods were reduce to 120
      • These 120 methods were manually analysed
    15. The Experiment with Fan In
      • For each method we took the following steps:
        • Analysis of the method code to get a perception of its functionality
        • Analysis of the call sites to get a perception of the context in which it was used
      • After inspection 45 methods were considered aspect seeds
        • It doesn’t mean that 45 aspects were found as some methods contribute to the same aspect
    16. The Experiment with Fan In
      • Summary of the concepts found
      Decorator 1 UndoableComand uses the decorator pattern Consistent Behaviour 1 Every UndoableAdapter calls its superclass constructor Consistent Behaviour 1 Every undo operation must call its superclass undo() Consistent Behaviour 1 Before doing a redo the method isRedoable() must be called Persistence 6 many figures use readInt, writeInt and such methods to write to a stream Consistent Behaviour 1 Every tool calls super.mouseDown()within their own mouseDown() Consistent Behaviour 2 Tool activation and deactivation Consistent Behaviour 1 Every tool class must call the superclass constructor Consistent Behaviour 2 After execution of commands (specially redos) the selection must be cleared Consistent Behaviour 4 After execution of commands/tools the view must be checked for damages Observer 7 FigureChangedListener Composite 10 Composite pattern in Figure hierarchy Decorator 1 Border decorator Consistent Behaviour 3 When a tool has finished execution method toolDone() must be called Concern type Methods Description
    17. The Experiment with Dynamic Analysis
      • This was the most difficult experiment
      • Before the experience was done an “instrumented version” had to be created, which took a long time
        • Every “.java” file was renamed to a “.oj” file
        • Every class, including inner classes, had to insert an “implements” clause for a dynamo interface
        • Every file had to add an import clause for the dynamo package
        • The resulting code was compiled with OpenJava whose result was several new “java” files – this compilation exceeded 5 hours
        • These files had to be compiled with the Java compiler
      • After the instrumentation was completed the use cases were run in the instrumented version
        • Running the use cases also takes a long time
    18. The Experiment with Dynamic Analysis
      • Summary of the concepts found
      1 1 Visitor 2 1 Managing view rectangle 2 1 Set Attribute 2 1 Get Attribute 2 1 Manage figures outside drawing 55 1 Connecting figures 25 1 Command executability 11 4 Figure Observer 60 4 Handle manipulation 30 1 Persistence 18 1 Connect text 3 1 Send to back 3 1 Bring to front 36 2 Undo Methods Concepts Description of concern
    19. The Experiment with Clone Detection
      • This was an easy experiment, we only needed to know which files to analyse and the results are fast to obtain
      • The first results included 433 clone sets, reduced to 79 after filtering clones with a population less than 4
      • These 79 clone sets were manually inspected
      • We found that some clone sets overlap and some clones had unrelated code (false clones)
      • After this initial inspection only 33 clone sets remained
    20. The Experiment with Clone Detection
      • Summary of the concerns found
      Observer 1 1 ViewChangeListener subject role + 2 DesktopListener subject roles Consistent behaviour 1 Many commands have to perform isExecutableWithView Decorator 1 3 instances of decorator Consistent behaviour 1 Every handle checks owner’s display box Consistent behaviour 1 Before executing commands isExecutable() must be called Observer 1 5 subjects roles of FigureListener Connecting figures 1 Connecting figures undo + event dispatcher 1 Event dispatcher + undo Handles 1 Handle manipulation Observer (2x) 1 1 subject roles of Figure Listener and 2 subject roles of DesktopListener Observer 1 2 subject roles of ViewListener Observer 2 1 observer role and 3 subject roles in FigureListener Persistence 1 Reading and writing data Undo 14 Undo Observer (2x) 4 1 subject roles in Observer pattern: Command Listener and Tool Listener Consistent behaviour 1 Tools must update the view after a mouseDown( ) Concern type Sets Description
    21. Comparing the Techniques
      • For the comparison we selected some concerns that were detected by all the techniques and some that were discovered by two or one
      • For each concern we discuss why the various techniques failed/succeed to identify it.
    22. Comparing the Techniques
      • Observer pattern
        • Every technique succeed to identify this concern
        • The Fan In and Dynamic analysis identified 1 while the Clone Detection discovered 5
    23. Comparing the Techniques
      • Composite pattern
        • Only the Fan In analysis succeeded to identify this concern
        • Clone detection failed because there are few instances of the pattern so clone population was low
        • Dynamic analysis failed to identify it because every trace uses the composite pattern
            • every drawing is a composite figure
    24. Comparing the Techniques
      • Undo
        • Both Clone Detection and Dynamic analysis detected this concern, but Fan In failed
        • Even though Fan In detected that all redo must do a isExecutable() this falls in the category of consistent behaviour
        • Clone Detection succeed because every undo activity has similar code – an inner class that has undo and redo methods
        • Dynamic analysis detected it because undo is considered a use case and so is exercised in the application
    25. Comparing the Techniques
      • Handle Manipulation
        • Both Clone Detection and Dynamic analysis detected this concern, but Fan In failed
        • Handle manipulation is used in the use cases that manipulate figures so the Dynamic analysis detects it fairly well
        • Clone Detection succeeded because much of the handles code is similar
        • Fan In failed because even though there are many methods related to the handle manipulation, each is called from very few points
    26. Comparing the Techniques
      • Consistent behaviour
        • Every technique identified this type of concern but they identified it in very different ways
        • The Fan In was the one that discovered more cases (9), Clone Detection also discovered a few (4), Dynamic analysis only detected 1
        • This is clearly the goal of the Fan In method were a specific concern is done by a method that is called from several places
        • Clone detection also detects this because some of the code is very similar (often involving an if statement with a method invocation followed by a return statement)
        • Dynamic analysis failed to detect most of the concerns because they are exercised in almost every use case
    27. Comparing the Techniques
      • Bring to Front/Send to back
        • Only Dynamic analysis detected this concern
        • Fan In failed because the methods dealing with it are not called from many places as it is a rather specific concern
        • Clone detection failed because the concerns code is specific to two classes and not repeated
    28. Comparing the Techniques
      • Summary of the comparison
          • A + means that a concern was found by the technique
          • A ++ means that the technique was more efficient than the others
      + Bring to Front/Send to back + (4) + (1) ++ (9) Consistent Behaviour + ++ Handle Manipulation ++ + Undo + Composite ++ + + Observer Clone Detection Dynamic Analysis Fan In Analysis Concern
    29. Comparing the Techniques
      • Limitations of Fan In
        • Mainly addresses crosscutting concerns that are largely scattered
        • It depends on the correct modularisation of the concerns in methods
          • If the code is not placed in methods but “copy/pasted” (unfortunelly not uncommon) the technique fails
        • A collateral effect is the anticipated unsuitability of the technique for analysing small case studies
    30. Comparing the Techniques
      • Limitations of Dynamic Analysis
        • It is partial as not all methods involved in an aspect are retrieved
        • It can determine only aspects that can be discriminated by different execution scenarios
        • Additionally, it does not deal with code that cannot be executed
    31. Comparing the Techniques
      • Limitations of Clone Detection
        • If a concern is handled differently by those who implement it the technique fails
        • If there are few classes that implement the concern it also fails
          • If there was only one instance of the Observer pattern (a ++ in this experiment) then Clone Detection would fail to discover it.
    32. Combining the Techniques
      • Fan-in analysis and dynamic analysis show largely complementary result sets
        • This means that they can be combined to achieve better results
      • A combination of Fan-in analysis and Clone Detection would give better results:
        • In the example of the Observer pattern Fan In identified the observers roles while Clone Detection identified the subject role.
        • In the badly written modularity (using copy/paste instead of method calling) Fan In would fail but Clone Detection would succeed and vice-versa
    33. Combining the Techniques
      • Overall the combination of the three techniques provides the best results
    34. Conclusion
      • Aspect Mining is an important step in refactoring legacy systems into Aspect Oriented ones
      • There are many techniques to do aspect mining so comparing them helps developers to chose wisely
    35. Conclusion
      • We compared 3 of those techniques and presented their strengths:
        • Fan In deals better with concerns that are implemented in methods that are called from the various places dealing with the concern
        • Dynamic analysis deals better with concerns that are associated with some of the application use cases
        • Clone Detection finds the crosscutting concerns that are implemented via replicated code
      • and weaknesses:
        • Fan In cannot handle concerns that are not much scattered or that are not implemented with methods calls but with in site code
        • Dynamic Analysis fails to discover the concerns that are common to all use cases and also fails to detect unused concerns
        • Clone Detection fails to address those concerns that have different code for each place that deals with it
    36. Conclusion
      • Finally we considered that combining the 3 techniques would benefit the final outcome
    37. Questions?

    + fcorreiafcorreia, 2 years ago

    custom

    948 views, 0 favs, 0 embeds more stats

    Presented on DSIE'08 - http://www.fe.up.pt/dsie08

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 948
      • 948 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 12
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Groups / Events