]> git.uio.no Git - ifi-stolz-refaktor.git/blob - presentation/master-presentation-erlenkr.tex
019b0954ed1dd06463c445bc29c6768e7bd17b5e
[ifi-stolz-refaktor.git] / presentation / master-presentation-erlenkr.tex
1 \documentclass[USenglish,9pt]{beamer}
2 \usepackage[utf8]{inputenc}
3 \usepackage[T1]{fontenc}
4 \usepackage{lmodern}
5 \usepackage{babel,textcomp}
6 \usepackage[style=alphabetic,backend=biber]{biblatex}
7 \usepackage{babel,textcomp,csquotes}
8 \usepackage{xspace}
9
10 \usepackage{varioref}
11 %\usepackage[hidelinks]{hyperref}
12 \usepackage{cleveref}
13
14 \usepackage{amsthm}
15 \usepackage{mathtools}
16
17 \usepackage{verbatim}
18 \usepackage{minted}
19 \usepackage{multicol}
20 %\usemintedstyle{bw}
21 \usemintedstyle{default}
22
23 \usetheme{Ifi}
24
25 \theoremstyle{definition}
26 \newtheorem*{wordDef}{Definition}
27 \newtheorem*{mytheorem}{Theorem}
28 \newcommand{\mydefinition}[1]{\begin{wordDef}#1\end{wordDef}}
29
30 \newcommand{\citing}[1]{~\cite{#1}}
31
32 \newcommand{\code}[1]{\texttt{\textbf{#1}}}
33 \newcommand{\type}[1]{\code{#1}}
34 \newcommand{\method}[1]{\type{#1}}
35 \newcommand{\var}[1]{\type{#1}}
36
37 \newcommand{\name}[1]{#1}
38 \newcommand{\tit}[1]{\emph{#1}}
39 \newcommand{\refa}[1]{\emph{#1}}
40 \newcommand{\pattern}[1]{\emph{#1}}
41 \newcommand{\metr}[1]{\emph{#1}}
42 \newcommand{\ExtractMethod}{\refa{Extract Method}\xspace}
43 \newcommand{\MoveMethod}{\refa{Move Method}\xspace}
44 \newcommand{\ExtractAndMoveMethod}{\refa{Extract and Move Method}\xspace}
45
46 \def\thetitle{Automated Composition of Refactorings}
47 \title{\thetitle}
48 \author{Erlend Kristiansen}
49
50 \bibliography{bibliography/master-thesis-erlenkr-bibliography}
51
52 \begin{document}
53
54 % Frame 1
55 \begin{frame}
56   \frametitle{\thetitle}
57   A short demonstration
58 \end{frame}
59
60 % Frame 2
61 \begin{frame}
62   \frametitle{Refactoring}
63   Martin Fowler, in his book on refactoring\citing{refactoring}, defines a 
64   refactoring:
65
66   \begin{quote}
67     \emph{Refactoring} (noun): a change made to the internal structure
68     of software to make it easier to understand and cheaper to modify without 
69     changing its observable behavior.~\cite[p.~53]{refactoring}
70   \end{quote}
71
72   If we leave the motivation behind refactoring out of the definition, it could 
73   be rephrased like this:
74
75   \begin{definition}
76     A \emph{refactoring} is a transformation
77     done to a program without altering its external behavior.
78   \end{definition}
79 \end{frame}
80
81 % Frame 3
82 \begin{frame}
83   \frametitle{Composite Refactorings}
84   There are \emph{primitive refactorings}. These refactorings cannot be 
85   expressed in terms of other refactorings. And there are \emph{composite
86   refactorings}:
87
88   \begin{definition}
89     A \emph{composite refactoring} is a refactoring that can be expressed in 
90     terms of two or more other refactorings.
91   \end{definition}
92 \end{frame}
93
94 % Frame 4
95 \begin{frame}
96   \frametitle{The Extract and Move Method refactoring}
97   This thesis is concentrating on creating a composite refactoring of the 
98   \ExtractMethod and \MoveMethod refactorings. The composition of the two is 
99   called the \ExtractAndMoveMethod refactoring.
100
101 \end{frame}
102
103 % Frame 5
104 \begin{frame}[fragile]
105   \frametitle{The Extract Method refactoring}
106   The \refa{Extract Method} refactoring is used to extract a fragment of code 
107   from its context and into a new method. A call to the new method is inlined 
108   where the fragment was before. It is used to break code into logical units, 
109   with names that explain their purpose
110
111   \begin{multicols}{2}
112     \begin{minted}[samepage]{java}
113   class C {
114     void method() {
115       // 1: Some code
116       // 2: Fragment
117       // 3: More code
118     }
119   }
120     \end{minted}
121
122     \columnbreak
123
124     \begin{minted}[samepage]{java}
125   class C {
126     void method() {
127       // 1: Some code
128       extractedMethod();
129       // 3: More code
130     }
131
132     void extractedMethod() {
133       // 2: Fragment
134     }
135   }
136     \end{minted}
137   \end{multicols}
138
139 \end{frame}
140
141 % Frame 6
142 \begin{frame}[fragile]
143   \frametitle{The Move Method refactoring}
144   The \refa{Move Method} refactoring is used to move a method from one class to 
145   another. This is useful if the method is using more features of another class 
146   than of the class which it is currently defined. 
147   
148   \begin{multicols}{2}
149     \begin{minted}[samepage]{java}
150   class C {
151     void method() {
152       X x = new X();
153       iBelongInX(x);
154     }
155     void iBelongInX(X x) {
156       x.foo(); x.bar();
157     }
158   }
159   
160   class X {
161     void foo(){/*...*/}
162     void bar(){/*...*/}
163   }
164     \end{minted}
165
166     \columnbreak
167
168     \begin{minted}[samepage]{java}
169   class C {
170     void method() {
171       X x = new X();
172       x.iBelongInX();
173     }
174   }
175
176   class X {
177     void iBelongInX() {
178       foo(); bar();
179     }
180     void foo(){/*...*/}
181     void bar(){/*...*/}
182   }
183     \end{minted}
184   \end{multicols}
185
186 \end{frame}
187
188 % frame 7/1
189 \begin{frame}[fragile]
190   \frametitle{The Composition}
191
192   \begin{multicols}{2}
193     \begin{minted}[samepage]{java}
194   // Before
195   class C {
196     void method() {
197       X x = new X();
198       x.foo(); x.bar();
199     }
200   }
201   
202   class X {
203     void foo(){/*...*/}
204     void bar(){/*...*/}
205   }
206     \end{minted}
207
208     \columnbreak
209
210 %    \begin{minted}[samepage]{java}
211 %  class C {
212 %    void method() {
213 %      X x = new X();
214 %      x.extractedMethod();
215 %    }
216 %  }
217 %
218 %  class X {
219 %    void extractedMethod() {
220 %      foo(); bar();
221 %    }
222 %    void foo(){/*...*/}
223 %    void bar(){/*...*/}
224 %  }
225 %    \end{minted}
226   \end{multicols}
227
228 \end{frame}
229
230 % Frame 7/2
231 \begin{frame}[fragile]
232   \frametitle{The Composition}
233
234   \begin{multicols}{2}
235     \begin{minted}[samepage]{java}
236   // Intermediate step
237   class C {
238     void method() {
239       X x = new X();
240       extractedMethod(x);
241     }
242     void extractedMethod(X x) {
243       x.foo(); x.bar();
244     }
245   }
246   
247   class X {
248     void foo(){/*...*/}
249     void bar(){/*...*/}
250   }
251     \end{minted}
252
253     \columnbreak
254
255 %    \begin{minted}[samepage]{java}
256 %  class C {
257 %    void method() {
258 %      X x = new X();
259 %      x.extractedMethod();
260 %    }
261 %  }
262 %
263 %  class X {
264 %    void foo(){/*...*/}
265 %    void bar(){/*...*/}
266 %  }
267 %    \end{minted}
268   \end{multicols}
269
270 \end{frame}
271
272 % Frame 7/3
273 \begin{frame}[fragile]
274   \frametitle{The Composition}
275
276   \begin{multicols}{2}
277     \begin{minted}[samepage]{java}
278   // Before
279   class C {
280     void method() {
281       X x = new X();
282       x.foo(); x.bar();
283     }
284   }
285   
286   class X {
287     void foo(){/*...*/}
288     void bar(){/*...*/}
289   }
290     \end{minted}
291
292     \columnbreak
293
294     \begin{minted}[samepage]{java}
295   // After
296   class C {
297     void method() {
298       X x = new X();
299       x.extractedMethod();
300     }
301   }
302
303   class X {
304     void extractedMethod() {
305       foo(); bar();
306     }
307     void foo(){/*...*/}
308     void bar(){/*...*/}
309   }
310     \end{minted}
311   \end{multicols}
312
313 \end{frame}
314
315 % Frame 8
316 \begin{frame}
317   \frametitle{Automation}
318
319   \begin{itemize}
320     \item Search based
321     \item Heuristics
322     \item Project wide search and perform
323   \end{itemize}
324
325 \end{frame}
326
327 % Frame 9
328 \begin{frame}
329   \frametitle{Demonstration}
330   \begin{itemize}
331     \item {The      
332         \code{LastStatementOfSelectionEndsInReturnOrThrow\-Checker.visit(IfStatement 
333         node)} method}
334       \begin{itemize}
335         \item Extract and Move on selection
336         \item Extract and Move, search based, on method
337       \end{itemize}
338     \item The \code{no.uio.ifi.refaktor} project
339       \begin{itemize}
340         \item Extract and Move, search based, over whole project
341       \end{itemize}
342   \end{itemize}
343
344 \end{frame}
345
346 \begin{frame}
347   \frametitle{What is left}
348   \begin{itemize}
349     \item Write technical section
350     \item Write up argument for correctness
351     \item Define the final case study
352     \item Run unit tests before and after change
353     \item Make more examples
354     \item Metrics?
355     \item \ldots
356   \end{itemize}
357  
358 \end{frame}
359
360 % Frame X
361 \begin{frame}
362   \frametitle{Bibliography}
363   \printbibliography
364 \end{frame}
365
366 \end{document}