Home

Péricles Alves

Fast

Overview

ConcernReCS is an Eclipse plug-in written to find Aspectization Code Smells, i.e., scenarios in source code that can lead to aspectization mistakes. Its main goal is to provide tooling support for programmers beginners in AOP and AspectJ, wich is one of the most used AO languages, in order to avoid mistakes during concern refactoring and aspectization.

Code Smells

Here we present a brief description of some aspectization code smells found in our previous studies

Primitive Concern Constant
  • Description: When developers are refactoring a concern that has one or more constant attributes of a primitive type, like the one extracted from the ATM application used in our previous studies and shown below, among its implementation elements they are likely to replace the uses of the attribute in the new aspect with its constant value. Therefore, the attribute becomes unreachable.

primitive_constant

  • May leads to: Duplicated crosscutting code
  • Error-proneness: 0.75
Static Concern Element
  • Description: Like other elements completely dedicated to a concern, the aspectization of static methods and attributes totally dedicated to a concern are supposed to be straightforward. However, we noticed that programmers tend to forget to refactor such elements.
  • May leads to: Incomplete refactoring
  • Error-proneness: 0.75
Attribute of a non-Dedicated Type
  • Description: When a concern has attributes of types not dedicated to its implementation, developers seem to be more prone to forget to refactor such attributes to aspects. The following figure illustrates this scenario by an example extracted from Telecom, an connection manager Java application. The Timer class is completely dedicated to the Timing concern in the Telecom application. The attribute shown in the right is more prone to be left in the base code.

att_non_dedic_type

  • May leads to: Incomplete refactoring
  • Error-proneness: 0.25
Divergent Join Point
  • Description: Consider a concern that has a call to a method in the begging of a method and all the others calls to the same method in the end of a method, or vice-versa. When all these calls should be refactored to a different advice, developers tend to use the wrong type of advice to refactor the only divergent call. The next figure illustrates this situation. The dashed element is the one more prone to be refactored with a wrong advice type.

div_jp

  • May leads to: Incorrect advice type
  • Error-proneness: 0.5
Element out of Inheritance Tree
  • Description: This code smell occurs when there is concern code, such as a call to a specific method or a read/write access to an attribute, completely dedicated to the concern in all leaves of an inheritance tree. However, there also is concern code in some other tree nodes (not leaves) or even in other classes of the OO system. When refactoring this specific kind of concern, developers are prone to forget to refactor to aspects those pieces of concern code that are not realized by a tree leaf. The following figure presents an abstract representation of this code smell. Dashed lines in the figure indicate elements that are prone to be left out in the concern aspectization.

div_jp

  • May leads to: Incomplete refactoring
  • Error-proneness: 0.75

Installing

ConcernReCS has been developed for Eclipse Indigo (3.7) and extends ConcernMapper 2.0.3. Therefore, it may not work properly with different versions of Eclipse and ConcerMapper.

Eclipse

Install Eclipse Indigo (3.7) or a newer version, which can be obtained at:
http://www.eclipse.org/downloads/

ConcernMapper

Open your Eclipse and go to "Help->Install New Software". In the "Work with" text box, put the following URL:
http://www.cs.mcgill.ca/~martin/cm/
Select "ConcernMapper" and press "next"/"finish" until the installation is complete.

ConcernReCS

Download the following file and extract it in your Eclipse "plugins" directory.
http://sourceforge.net/projects/concernrecs/files/ConcernReCS_binary.zip/download

Getting Started

Since you have followed the steps above, you are able to get started with ConcernReCS.
OBS: The following content is also available in our demo video:
http://www.youtube.com/watch?v=xTpI2XwfSjY&feature=youtu.be

Importing a project

The first step is to get the Java project in which the Code Smells will be sought. You can use your own project, but to make things easier you can download one of the following example projects, which had been used in our experiment to find Aspectization Code Smells:
- ATM: An Java application that simulates the basic activities of a conventional cash machine, such as withdrawing money, making a deposit, and issuing the account balance. (Default user: "12345"/password: "54321")
- Chess: Implements a chess game with graphical user interface.
- Telecom: A connection management system for phone calls, which simulates a call between two customers.

Mapping the Concerns

The next step is to map the desired concerns in the ConcernMapper tool.
In Eclipse go to "Window->Show View->Other...", then find and select ConcernMapper as shown bellow.
cm_show_view
To map a concern, you should drag and drop the Dedicated implementation elements, i.e., those Java elements, such as classes, methods and attributes, whose the code is completely dedicated to the concern, into the ConcernMapper view. Each of the example projects above comes with their respective concerns already mapped in a ".cm" file in the project fold. To visualize them, drag and drop the ".cm" file into the ConcernMapper view.
For instance, the ErrorMessages concern in the Chess application is mapped as follows.
errormessages_map

Setting Up User Preferences

It is possible to select which Code Smells should be sought by the ConcernReCS tool and in which concerns.
To enable/disable a Code Smell or a concern, in the Eclipse IDE go to "Window->Preferences" (for Windows/Linux users) or "Eclipse->Preferences" (for MacOS users), then choose "ConcernReCS".
As an example, the preferences for the Chess application are the following.
chess_preferences

Finding Aspectization Code Smells

To open the ConcernReCS view, go to "Window->Show View->Other...", then find and select ConcernReCS like in the following picture.
crcs_show_view
The view presenting the Code Smells found in the Chess application is depicted and described below.
crcs_view
- Refresh Action: Refresh the results by looking for Aspectization Code Smells in the concerns.
- Search Box: Simple text pattern search in the Code Smells being presented in the view.
- Save Action: Save the found Code Smells in a XML file.

For each Code Smell found in the concerns is presented the following information:
- Name: The simple name of the Code Smell.
- Mistake: The aspectization mistake that this Code Smell can lead to.
- Concern: The concern in which the Code Smell appears.
- Error-proneness: A number ranging from zero to one, indicating how prone a developer is to make a mistake when this Code Smell appears in the application code.
- Source: Source file in which the Code Smell is.
- Where: Which code element is related to this Code Smell.