-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsgc.tex
262 lines (230 loc) · 10.4 KB
/
sgc.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Beamer Presentation
% LaTeX Template
% Version 1.0 (10/11/12)
%
% This template has been downloaded from:
% http://www.LaTeXTemplates.com
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----------------------------------------------------------------------------------------
% PACKAGES AND THEMES
%----------------------------------------------------------------------------------------
\documentclass{beamer}
\mode<presentation> {
% The Beamer class comes with a number of default slide themes
% which change the colors and layouts of slides. Below this is a list
% of all the themes, uncomment each in turn to see what they look like.
%\usetheme{default}
%\usetheme{AnnArbor}
%\usetheme{Antibes}
%\usetheme{Bergen}
%\usetheme{Berkeley}
%\usetheme{Berlin}
%\usetheme{Boadilla}
%\usetheme{CambridgeUS}
%\usetheme{Copenhagen}
%\usetheme{Darmstadt}
%\usetheme{Dresden}
%\usetheme{Frankfurt}
%\usetheme{Goettingen}
%\usetheme{Hannover}
%\usetheme{Ilmenau}
%\usetheme{JuanLesPins}
%\usetheme{Luebeck}
\useinnertheme[shadow=true]{rounded}
\useoutertheme{infolines}
\usecolortheme{wolverine}
\setbeamerfont{block title}{size={}}
\setbeamercolor{titlelike}{parent=structure,bg=yellow!85!orange}
%\usetheme{Malmoe}
%\usetheme{Marburg}
%\usetheme{Montpellier}
%\usetheme{PaloAlto}
%\usetheme{Pittsburgh}
%\usetheme{Rochester}
%\usetheme{Singapore}
%\usetheme{Szeged}
%\usetheme{Warsaw}
% As well as themes, the Beamer class has a number of color themes
% for any slide theme. Uncomment each of these in turn to see how it
% changes the colors of your current slide theme.
%\usecolortheme{albatross}
%\usecolortheme{beaver}
%\usecolortheme{beetle}
%\usecolortheme{crane}
%\usecolortheme{dolphin}
%\usecolortheme{dove}
%\usecolortheme{fly}
%\usecolortheme{lily}
%\usecolortheme{orchid}
%\usecolortheme{rose}
%\usecolortheme{seagull}
%\usecolortheme{seahorse}
%\usecolortheme{whale}
%\usecolortheme{wolverine}
%\setbeamertemplate{footline} % To remove the footer line in all slides uncomment this line
%\setbeamertemplate{footline}[page number] % To replace the footer line in all slides with a simple slide count uncomment this line
%\setbeamertemplate{navigation symbols}{} % To remove the navigation symbols from the bottom of all slides uncomment this line
}
\usepackage{graphicx} % Allows including images
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
%----------------------------------------------------------------------------------------
% TITLE PAGE
%----------------------------------------------------------------------------------------
\title[Redistribute Responsibilities]{Eliminate Navigation Code \& Split Up God Class} % The short title appears at the bottom of every slide, the full title is only on the title page
\author{Hayat BELLAFKIH} % Your name
\institute[UMONS] % Your institution as it will appear on the bottom of every slide, may be shorthand to save space
{
University of Mons\\ % Your institution for the title page
\medskip
\textit{[email protected]} % Your email address
}
\date{\today} % Date, can be changed to a custom date
\begin{document}
\begin{frame}
\titlepage % Print the title page as the first slide
\end{frame}
\begin{frame}
\frametitle{Overview} % Table of contents slide, comment this block out to remove it
\tableofcontents[hideallsubsections] % Throughout your presentation, if you choose to use \section{} and \subsection{} commands, these will automatically be printed on this slide as an overview of your presentation
\end{frame}
%----------------------------------------------------------------------------------------
% PRESENTATION SLIDES
%----------------------------------------------------------------------------------------
%------------------------------------------------
\section{Introduction}
%------------------------------------------------
\begin{frame}
\frametitle{Introduction}
A systems reengineering pattern is a description of an expert solution to a common systems reengineering problem, including its name, context, advantages and disadvantages.
\end{frame}
\begin{center}
\begin{frame}
Eliminate Navigation Code
\end{frame}
\end{center}
\section{Eliminate Navigation Code}
\subsection{About the pattern}
\begin{frame}
\frametitle{Description}
The objective of Eliminate Navigation Code is to reduce the impact of changes by shifting responsibility down a chain of connected classes. The problem is these changes in the interfaces of a class will affect not only direct clients, but also all the indirect clients that navigate to reach it. \\
\setlength{\parskip}{10pt plus 1pt minus 1pt}
$\ast$ Split up a class with too many responsibilities into a number of smaller, cohesive classes.
\end{frame}
\subsection{How to resolve the Navigation code pattern ?}
\begin{frame}
\frametitle{Solution}
Iteratively move behavior defined by an indirect client to the container of the data on which it operates.\\
The recipe for eliminating navigation code is to recursively Move Behavior Close to Data. That can be done by:
\begin{enumerate}
\item Identify the navigation code to move.
\item Apply Move Behavior Close to Data to remove one level of navigation.
\item Repeat, if necessary.
\end{enumerate}
Deciding when to apply Eliminate Navigation Code can be difficult.
\end{frame}
\subsection{How to detect the presence of Navigation Code ?}
\begin{frame}
\frametitle{Detection}
\begin{itemize}
\item indirect providers:
\begin{itemize}
\item Each time a class changes for example by modifying its internal representation or collaborators, not only its direct but also indirect client classes have to be changed.
\item Look for classes that contain a lot public attributes, accessor methods or methods returning as value attributes of the class.
\item Big aggregation hierarchies containing mostly data classes often play the role of indirect provider.
\end{itemize}
\item indirect clients:
\begin{itemize}
\item A sequence of attribute accesses.
\item A sequence of accessor method calls.
\end{itemize}
\end{itemize}
\end{frame}
\begin{frame}
\frametitle{Detection (II)}
\begin{itemize}
\item Navigation code can be detected by simple pattern matching.
\item It is possible to use additional variables for disguise navigation code.
\end{itemize}
\end{frame}
\begin{center}
\begin{frame}
Split Up God Class
\end{frame}
\end{center}
\section{God class pattern}
\subsection{Why Split Up God Class ?}
\begin{frame}
\frametitle{Importance of splitting a God Class:}
\begin{itemize}
\item A god class monopolizes control of an application. Evolution of the application is difficult because nearly every change touches this class, and affects multiple responsibilities.
\item It is difficult to understand the different abstractions that are intermixed in a god class. Most of the data of the multiple abstractions are accessed from different places.
\item Identifying where to change a feature without impacting the other functionality or other objects in the system is difficult.
\item It is nearly impossible to change a part of the behavior of a god class in a black-box way.
\end{itemize}
\end{frame}
\subsection{Solution}
\begin{frame}
\frametitle{Solution}
Incrementally redistribute the responsibilities of the god class either to its collaborating classes or to new classes that are pulled out the god class. When there is nothing left of the god class but a facade, remove or deprecate the facade.\\
A god class is refactored in two stages, first by redistributing responsibilities to data containers, or by spawning off new classes, until there is nothing left but a facade, and second by removing the facade.
\begin{figure}[H]
\includegraphics[width=9cm]{steps-god-class.png}
\caption{Steps of splitting a god class}
\end{figure}
\end{frame}
\subsection{How detect a God class ?}
\begin{frame}
\frametitle{Detection}
A god class may be recognized in various ways:
\begin{itemize}
\item A single huge class treats many other classes as data structures.
\item A “root” class or other huge class has a name containing words like “System”, “Subsystem”, “Manager”, “Driver”, or “Controller”.
\item Changes to the system always result in changes to the same class.
\item Changes to the class are extremely difficult because you cannot identify which parts of the class They affect.
\item Reusing the class is nearly impossible because it covers too many design concerns.
\item The class is a domain class holding the majority of attributes and methods of a system or subsystem.
\item The class has an unrelated set of methods working on separated instance variables.
\item The class requires long compile times, even for small modifications.
\item The class is difficult to test due to the many responsibilities it assumes.
\item ... % list ather points during the presentation
\end{itemize}
\end{frame}
\subsection{Solution in steps}
%apply Regression Test After Every Change.
\subsubsection{Step 1}
\begin{frame}
\frametitle{Step 1}
Identify cohesive subsets of instance variables of the god class, and convert them to external data containers. Change the initialization methods of the god class to refer to instances of the new data containers.
\end{frame}
\subsubsection{Step 2}
\begin{frame}
\frametitle{Step 2}
Identify all classes used as data containers by the god class and apply Move Behavior Close to Data to promote the data containers into service providers.
\end{frame}
\subsubsection{Step 3}
\begin{frame}
\frametitle{Step 3}
After iteratively applying steps 1 and 2, there will be nothing left of the god class except a facade with a big initialization method. Shift the responsibility for initialization to a separate class, so only a pure facade is left.
\end{frame}
\subsection{Difficulties of splitting a God Class}
\begin{frame}
\frametitle{Difficulties of splitting a God Class}
God class methods may themselves be large, procedural abstractions with too many responsibilities. Such methods may need to be decomposed before cohesive sets of instance variables and methods can be teased out as classes.
\end{frame}
%----------------------------------------------------------------------------------------
\section{References}
\begin{frame}
\frametitle{References}
\footnotesize{
\begin{thebibliography}{99} % Beamer does not support BibTeX so references must be inserted manually as below
\bibitem[Smith, 2012]{p1} Serge Demeyer, Stéphane Ducasse, Oscar Nierstrasz
\newblock Object-Oriented Reengineering Patterns
\end{thebibliography}
}
\end{frame}
\end{document}