]> git.uio.no Git - ifi-stolz-refaktor.git/blobdiff - thesis/master-thesis-erlenkr.tex
Thesis: writing about the Extract and Move Method refactoring
[ifi-stolz-refaktor.git] / thesis / master-thesis-erlenkr.tex
index fe4cae8101fa7d375cf504e77c99eeffdb0802fd..eaf92300ff758d375bde2a6b8306947d92a6e800 100644 (file)
@@ -1200,7 +1200,10 @@ extract into new methods.
 \section{The problem statement}
 \todoin{write/move}
 
-\section{The refactorings}
+\section{The primitive refactorings}
+The refactorings presented here are the primitive refactorings used in this 
+project. They are the abstract building blocks used by the \ExtractAndMoveMethod 
+refactoring. 
 
 \subsection{The Extract Method refactoring}
 The \refa{Extract Method} refactoring is used to extract a fragment of code 
@@ -1212,9 +1215,8 @@ An example of an \ExtractMethod refactoring is shown in
 \myref{lst:extractMethodRefactoring}. It shows a method containing calls to the 
 methods \method{foo} and \method{bar} of a type \type{X}. These statements are 
 then extracted into the new method \method{fooBar}.
-\todoin{Refine}
 
-\begin{listing}
+\begin{listing}[h]
   \begin{multicols}{2}
     \begin{minted}[samepage]{java}
   // Before
@@ -1253,9 +1255,7 @@ class than of the class which it is currently defined.
 \Myref{lst:moveMethodRefactoring} shows an example of this refactoring. Here a 
 method \method{fooBar} is moved from the class \type{C} to the class \type{X}.
 
-\todoin{Refine}
-
-\begin{listing}
+\begin{listing}[h]
   \begin{multicols}{2}
     \begin{minted}[samepage]{java}
   // Before
@@ -1299,10 +1299,60 @@ method \method{fooBar} is moved from the class \type{C} to the class \type{X}.
   \label{lst:moveMethodRefactoring}
 \end{listing}
 
-\subsection{The Extract and Move Method refactoring}
-\todoin{Write}
-\missingfigure{Explaining the Extract and Move Method refactoring}
+\section{The Extract and Move Method refactoring}
+The \ExtractAndMoveMethod refactoring is a composite refactoring composed of the 
+primitive \ExtractMethod and \MoveMethod refactorings. The effect of this 
+refactoring on source code is the same as when extracting a method and moving it 
+to another class. Conseptually, this is done without an intermediate step. In 
+practice, as we shall see later, an intermediate step may be necessary.
 
+An example of this composite refactoring is shown in 
+\myref{lst:extractAndMoveMethodRefactoring}. The example joins the examples from 
+\cref{lst:extractMethodRefactoring} and \cref{lst:moveMethodRefactoring}. This 
+means that the selection consisting of the consecutive calls to the methods 
+\method{foo} and \method{bar}, is extracted into a new method \method{fooBar} 
+located in the class \type{X}.
+
+\begin{listing}[h]
+  \begin{multicols}{2}
+    \begin{minted}[samepage]{java}
+  // Before
+  class C {
+    void method() {
+      X x = new X();
+      x.foo(); x.bar();
+    }
+  }
+  
+  class X {
+    void foo(){/*...*/}
+    void bar(){/*...*/}
+  }
+    \end{minted}
+
+    \columnbreak
+
+    \begin{minted}[samepage]{java}
+  // After
+  class C {
+    void method() {
+      X x = new X();
+      x.fooBar();
+    }
+  }
+
+  class X {
+    void fooBar() {
+      foo(); bar();
+    }
+    void foo(){/*...*/}
+    void bar(){/*...*/}
+  }
+    \end{minted}
+  \end{multicols}
+  \caption{An example of the \ExtractAndMoveMethod refactoring.}
+  \label{lst:extractAndMoveMethodRefactoring}
+\end{listing}
 
 \section{Choosing the target language}
 Choosing which programming language the code that shall be manipulated shall be 
@@ -1802,7 +1852,8 @@ text selection spanned out by the two addends.
 represents a text selection.}
 \label{lst:textSelectionsExample}
 \end{listing}
-\todoin{fix \myref{lst:textSelectionsExample}?}
+\todoin{fix \myref{lst:textSelectionsExample}? Text only? All 
+sub-sequences\ldots}
 
 \paragraph{Finding the candidate} for the refactoring is done by analyzing all 
 the generated text selection with the \type{ExtractAndMoveMethodAnalyzer}