-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
340 lines (331 loc) · 14.7 KB
/
index.html
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>reveal.js</title>
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/monokai.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>
<span>S</span><span class="fragment" data-fragment-index="1">.</span><span>O</span><span class="fragment" data-fragment-index="1">.</span><span>L</span><span class="fragment" data-fragment-index="1">.</span><span>I</span><span class="fragment" data-fragment-index="1">.</span>D
</h1>
</section>
<section>
<section>
<h3>
<span>S</span><span class="fragment" data-fragment-index="2">ingle</span>
<span class="fragment" data-fragment-index="1">R</span><span class="fragment" data-fragment-index="2">esponsibility</span>
<span class="fragment" data-fragment-index="1">P</span><span class="fragment" data-fragment-index="2">rinciple</span>
</h3>
<q class="fragment" data-fragment-index="3">A module should have one, and only one, reason to change</q>
</section>
<section>
<h4>Single Responsiblity Principle</h4>
<div>Before</div>
<pre>
<code data-trim data-noescape>
class ChessBoard {
protected $board;
public function __construct($size){}
public function placeQueen($x, $y){}
public function renderToScreen(){}
public function renderToJSON(){}
}
</code>
</pre>
</section>
<section>
<h4>Single Responsiblity Principle</h4>
<div>After</div>
<pre>
<code data-trim data-noescape>
class ChessBoard {
protected $board;
public function __construct($size){}
public function placeQueen($x, $y){}
}
</code>
</pre>
<pre>
<code data-trim data-noescape>
class ChessBoardRenderer {
protected $chessBoard;
public function __construct(ChessBoard $chessBoard){}
public function renderToScreen(){}
public function renderToJSON(){}
}
</code>
</pre>
</section>
</section>
<section>
<section>
<h3>
<span>O</span><span class="fragment" data-fragment-index="2">pen-</span><span class="fragment" data-fragment-index="1">C</span><span class="fragment" data-fragment-index="2">losed</span>
<span class="fragment" data-fragment-index="1">P</span><span class="fragment" data-fragment-index="2">rinciple</span>
</h3>
<q class="fragment" data-fragment-index="3">A software artifact should be open for extension but closed for modification</q>
</section>
<section>
<h4>Open-closed principle</h4>
<div>Before</div>
<pre>
<code data-trim data-noescape>
class ChessBoard {
protected $board;
public function __construct($size){}
public function placeQueen($x, $y){}
}
</code>
</pre>
<pre>
<code data-trim data-noescape>
class ChessBoardRenderer {
protected $chessBoard;
public function __construct(ChessBoard $chessBoard){}
public function renderToScreen(){}
public function renderToJSON(){}
}
</code>
</pre>
</section>
<section>
<h4>Open-closed principle</h4>
<div>After</div>
<pre>
<code data-trim data-noescape>
class ChessBoard {
protected $board;
public function __construct($size){}
public function placeQueen($x, $y){}
}
</code>
</pre>
<pre>
<code data-trim data-noescape>
interface ChessBoardRenderer
{
public function render();
}
</code>
</pre>
</section>
<section>
<h4>Open-closed principle</h4>
<div>After</div>
<pre>
<code data-trim data-noescape>
class ScreenChessBoardRenderer implements ChessBoardRenderer {
protected $chessBoard;
public function __construct(ChessBoard $chessBoard){}
public function render(){}
}
</code>
</pre>
<pre>
<code data-trim data-noescape>
class JSONChessBoardRenderer implements ChessBoardRenderer {
protected $chessBoard;
public function __construct(ChessBoard $chessBoard){}
public function render(){}
}
</code>
</pre>
</section>
</section>
<section>
<section>
<h3>
<span>L</span><span class="fragment" data-fragment-index="2">iskov</span>
<span class="fragment" data-fragment-index="1">S</span><span class="fragment" data-fragment-index="2">ubstitution</span>
<span class="fragment" data-fragment-index="1">P</span><span class="fragment" data-fragment-index="2">rinciple</span>
</h3>
<q class="fragment" data-fragment-index="3">
What is wanted here is something like the following substitution property: If for each object o1 of type S there is an object o2 of type T such that for all programs P defined in terms of T, the behavior of P is unchanged when o1 is substituted for o2 then S is a subtype of T
</q>
</section>
<section>
<h4>Liskov Substitution Principle</h4>
<span>Before</span>
<pre>
<code data-trim data-noescape>
class Rectangle {
protected $width;
protected $height;
public function __construct($width, $height){}
public function area(){}
}
class Square extends Rectangle {}
class Main {
public static function getArea(Rectangle $rectangle) {
return $rectangle->area();
}
}
</code>
</pre>
</section>
<section>
<h4>Liskov Substitution Principle</h4>
<span>After</span>
<pre>
<code data-trim data-noescape>
interface AreaCalculateable
{
public function area();
}
</code>
</pre>
</section>
<section>
<h4>Liskov Substitution Principle</h4>
<span>After</span>
<pre>
<code data-trim data-noescape>
class Rectangle implements AreaCalculateable {
protected $width;
protected $height;
public function __construct($width, $height){}
public function area(){}
}
</code>
</pre>
<pre>
<code data-trim data-noescape>
class Square implements AreaCalculateable {
protected $side;
public function __construct($side){}
public function area(){}
}
</code>
</pre>
</section>
<section>
<h4>Liskov Substitution Principle</h4>
<span>After</span>
<pre>
<code data-trim data-noescape>
class Main {
public static function getArea(AreaCalculateable $shape) {
return $shape->area();
}
}
</code>
</pre>
</section>
</section>
<section>
<section>
<h3>
<span>I</span><span class="fragment" data-fragment-index="2">nterface</span>
<span class="fragment" data-fragment-index="1">S</span><span class="fragment" data-fragment-index="2">egregation</span>
<span class="fragment" data-fragment-index="1">P</span><span class="fragment" data-fragment-index="2">rinciple</span>
</h3>
</section>
<section>
<h4>Interface Segregation Principle</h4>
<span>Before</span>
<pre>
<code data-trim data-noescape>
interface ShapeInterface {
public function area();
public function volume();
}
</code>
</pre>
</section>
<section>
<h4>Interface Segregation Principle</h4>
<span>After</span>
<pre>
<code data-trim data-noescape>
interface FlatShapeInterface {
public function area();
}
</code>
</pre>
<pre>
<code data-trim data-noescape>
interface SolidShapeInterface {
public function volume();
}
</code>
</pre>
</section>
</section>
<section>
<section>
<h3>
<span>D</span><span class="fragment" data-fragment-index="2">ependency</span>
<span class="fragment" data-fragment-index="1">I</span><span class="fragment" data-fragment-index="2">nversion</span>
<span class="fragment" data-fragment-index="1">P</span><span class="fragment" data-fragment-index="2">rinciple</span>
</h3>
</section>
<section>
<h4>Dependency Inversion Principle</h4>
<span>Before</span>
<pre>
<code data-trim data-noescape>
class Controller {
public function __construct(){}
public function save()
{
$db = new MysqlDB();
$db->save($this);
}
}
</code>
</pre>
</section>
<section>
<h4>Dependency Inversion Principle</h4>
<span>After</span>
<pre>
<code data-trim data-noescape>
class Controller {
public function __construct(DB $db){}
public function save() {
$this->db->save($this);
}
}
</code>
</pre>
</section>
</section>
<section>
<h4>Thanks!</h4>
</section>
</div>
</div>
<script src="js/reveal.js"></script>
<script>
// More info about config & dependencies:
// - https://github.com/hakimel/reveal.js#configuration
// - https://github.com/hakimel/reveal.js#dependencies
Reveal.initialize({
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true }
],
transition: 'fade',
});
</script>
</body>
</html>