Fan-in analysis

Fan-in analysis is aimed at identifying crosscutting concerns whose implementation is scattered over a large number of elements, and consists of method invocations. Examples of such concerns include consistent logging or tracing, consistent notification of events, exception handling and wrapping, etc. In all these cases, the crosscutting functionality is typically implemented by a method and invoked from a large number of places.

The number of invocations to a method gives the value of the fan-in metric of that method. Fan-in analysis looks for program elements that implement crosscutting functionality (seeds) among methods with a high value of their fan-in metric. That is, methods that are called from many, scatered places are reported as candidate-seeds. The human analyzer investigates the candidates using a number of guidelines (mainly, relationships between callers), and rejects or accepts a candidate as a seed.

Running the analysis

Fan-in is the default (and the first) analysis to run in FINT: the user selects an element in Eclipse's Package Explorer, and then the Fan-in option from the element's context menu.

 

The results of the analysis are displayed in the Fan-in Analysis View: From Eclipse's menu select Window -> Show View -> Other... -> FINT and open the Fan-in Analysis View.

 

 

The view displays the methods of the analyzed element (in this case, a Java project) as a tree hierarchy - each method is the parent of its callers.

The fan-in value of a callee is displayed next to its qualified name.

 

The view presents the user with a number of options:

 Note: The filter for accessors also checks methods in interfaces and eliminates those for which all implementations are accessors.

By double-clicking any element in the view, the user can inspect the code for that element.

Further on, it is possible to:

 

The analysis settings include the accessor and library filters as well as:

Callees filters

and Callers filters

 

To select "utility" elements, the user is presented with the Java element hierarchy of the analyzed Java element. The user can check the "utility" elements in the dialog window of the Fan-in Analysis Setup. Such utility elements could include, for instance, (JUnit) test packages, as in the shown example.

Reason and decide about a candidate

If the user decides that a candidate is a seed, she/he can mark it as such by selecting the Mark Seed option from the context menu of the candidate - (to access the menu, right-click the candidate in the view). The same option for a seed un-marks the candidate.

 

 

To reason about a candidate, select it in the view and choose Go Into from its context menu. This command opens the list of its callers and activates the toolbar button for launching various analyses for the callers.

By selecting this button, the user is presented with a number of options for various analyses. For instance, the option for analyzing the hierarchies of the callers will check the top-level declaring interfaces/classes of each caller, and highlight with the same color those methods that are declared by the same type (see the figure above).

 

The option for analyzing the position of the calls to the high fan-in (analyzed) method opens a window that shows all the callers of the method and the position of the calls to this method. The positions are relative to the caller's body.

 

 

References: