Skip to main content
QUICK REVIEW

[Paper Review] Refactoring Composite to Visitor and Inverse Transformation in Java

Akram Ajouli, Julien Cohen|arXiv (Cornell University)|Dec 19, 2011
Software Engineering ResearchComputer Science20 references5 citations
TL;DR

This paper presents a systematic, tool-supported refactoring approach to transform Java programs using the Composite design pattern into equivalent programs using the Visitor pattern, and vice versa, preserving external behavior. The key contribution is a formally specified transformation scheme with automated refactoring operations in IntelliJ IDEA and Eclipse, validated on the JHotDraw framework with correct round-trip semantics and precondition generation.

ABSTRACT

We describe how to use refactoring tools to transform a Java program conforming to the Composite design pattern into a program conforming to the Visitor design pattern with the same external behavior. We also describe the inverse transformation. We use the refactoring tool provided by IntelliJ IDEA.

Motivation & Objective

  • To enable automated, behavior-preserving transformation between Composite and Visitor design patterns in Java.
  • To ensure round-trip correctness, meaning that transforming from Composite to Visitor and back yields the original program structure.
  • To generate minimal preconditions that guarantee the safety and correctness of each transformation step.
  • To validate the approach on a real-world system, specifically the JHotDraw framework.
  • To provide a reusable, formalized set of refactoring operations for pattern migration in object-oriented systems.

Proposed method

  • The authors define a bidirectional transformation scheme between Composite and Visitor patterns using a sequence of atomic refactoring operations.
  • They implement the transformations using automated refactoring tools from IntelliJ IDEA and Eclipse, ensuring syntactic and semantic correctness.
  • The method includes generating minimal preconditions using symbolic execution and static analysis to ensure transformation safety.
  • A set of 33 atomic refactoring operations (e.g., MoveMethod, PullUpImplementation, InlineClass) is formally specified to handle complex class hierarchies and method duplication.
  • The approach supports variants such as methods with parameters, different return types, and interface-based hierarchies.
  • The transformation is validated on JHotDraw, where both forward and reverse transformations are applied and verified for correctness.

Experimental results

Research questions

  • RQ1Can a fully automated, behavior-preserving refactoring from Composite to Visitor be achieved in Java using standard IDE tools?
  • RQ2What is the minimal set of preconditions required to ensure the correctness of the Composite-to-Visitor transformation?
  • RQ3Can the inverse transformation from Visitor back to Composite be achieved with the same behavioral guarantees?
  • RQ4How do variations such as parameterized methods, different return types, and interface-based hierarchies affect the transformation process?
  • RQ5Can the transformation scheme be successfully applied and verified on a real-world system like JHotDraw?

Key findings

  • The transformation from Composite to Visitor and back preserves external behavior, confirming round-trip correctness.
  • The method successfully generated minimal preconditions for the base transformation, ensuring safety and correctness.
  • The approach was successfully applied to JHotDraw, demonstrating feasibility on a real-world application with complex class hierarchies.
  • The transformation scheme handles complex variants, including methods with parameters, different return types, and multi-level inheritance.
  • The use of formal refactoring operations (e.g., MoveMethod, PullUpImplementation) enabled precise and reliable restructuring of code.
  • The generated preconditions were validated using symbolic execution and static analysis, ensuring correctness of the transformation pipeline.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.