Start Here: Visitor Pattern and the Quark Application

This is an experiment on object-oriented refactoring.  The first part of this experiment is for you to refresh your knowledge of the Visitor design pattern and a simple program, called "quark", that is to be refactored. When you feel comfortable with both the visitor-patten and "quark", you can proceed to the refactoring assignment.

1. Visitor Pattern

The Visitor Pattern is a classical object-oriented design pattern. The basic idea is to move all methods (typically within the same class hierarchy) with the same signature (return type, method name, parameter types in order) into a single class, called "Visitor", and do so without altering the behavior of the program. Below, choose one or more of the links to watch or read in order to understand what visitor pattern is and how it works.
The figure below summarizes the transformation (where the method becomes Visitor.visit(A), becomes Visitor.visit(B), etc.). singleton is a static member of type "Visitor" in the class "Visitor". We say or or "seeds" the visitor-pattern. That is, moving any of these methods into the "Visitor" class will cause the rest to be moved as well (since they belong to the same class hierarchy).

Your first task is to understand what visitor pattern is, how it is created, and how and why it works. This might take 1/2 hour of your time, more or less, to get the idea. If you have questions, ASK!

2. Quark Application

Quark is an simple Java GUI.  A class diagram of its organization is shown below:

The root is an abstract class called Tree, which has 4 methods (there may be more methods, but only these are shown):
  • tree apply(I i)
  • tree apply(A a)
  • tree apply(H h)
  • tree apply(G g)
All classes in this hierarchy implement or inherit these methods. The semantics (meaning) of these methods is not significant for this assignment, only to the extent that one of these methods (to be revealed later) will be involved with a visitor pattern.  Here is your task:
> java -jar Quark.jar

Note: if you can't execute Quark.jar (you get a Major/Minor error), your JDK/JRE is out of date.  Use JRE1.7, JDK1.7+.  
What you can do is just jump to Step 3 below, install Eclipse. In the following assignment, I will give you the source
for Quark and you can compile and run it then.
Spend a minute or so on the above.

3. Install Eclipse 4.4.2

Download and install Eclipse JDT Classic 4.2.2 (Juno). Use ONLY this version of Eclipse.

What To Submit

Follow this link to a survey, and answer the questions posed.  At the bottom of the survey is a URL to the next task for you to do.