/
index.html
484 lines (446 loc) · 21.1 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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
<!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/reveal.css">
<link rel="stylesheet" href="css/theme/simple.css">
<link rel="stylesheet" href="css/custom.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.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>
<h2>Values and principles</h2>
<p>in software design.</p>
<img src="cas2017.png" width="300"/>
</section>
<section>
<div>
<span style="margin-right: 70px; margin-bottom: 30px">
<img src="codesai.jpeg" width="320"/>
</span>
<span style="margin-right: 70px">
<img src="agilecanarias.jpeg" width="160"/>
</span>
</div>
<span style="margin-right: 90px; margin-bottom: 30px">
<h3 style="display: inline">Fran Reyes -</h3>
<span>
<img src="twitter.png" width="80px" style="vertical-align: middle; margin-bottom: 30px"/>
<h3 style="display: inline">fran_reyes</h3>
</span>
</section>
<section><h3>Values, principles and patterns form a balanced expression of a <span style="color: rgb(128, 85,196)">style of development.</span></h3></section>
<section>
<h3>Differents values and differents principles will lead to different styles.</h3>
</section>
<section>
<blockquote>“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”</blockquote>
<p>San Martin de Fowler</p>
</section>
<section>
<ul style="list-style-type: none">
<li>Patterns describe what to do.</li>
<li>Values provide motivation.</li>
<li>Principles help translate motive into action.</li>
</ul>
<p style="color: grey; font-size: 30px" class="fragment">Principles bridge values (universal but often difficult to apply directly) and patterns (which are clear to apply but specific).</p>
</section>
<section>
<h3>Communication, Simplicity and Flexibility</h3>
<img src="implementation-patterns.jpg"/>
</section>
<section>
<section>
<h3>Software Economics</h3>
<img src="money.gif" />
</section>
<section>
<h3>Software Economics</h3>
<p>Cost Understand + Cost Change + Cost Test + Cost Deploy
</section>
</section>
<section>
<h3><b>Communication</b></h3>
<p>Code communicates well when a reader can understand it, modify it, or use it.</p>
</section>
<section>
<section>
<p>What is the purpose of this code?</p>
<pre><code data-trim data-noescape>
public List<int> getThem(){
var list1 = new List<int>();
forEach(var x : TheList){
if(x.Status == 4) {
list1.add(x.Id);
}
}
return list1;
}
</code></pre>
</section>
<section>
<p >What kinds of things are in the List?</p>
<pre class="fragment"><code data-trim data-noescape>
public List<int> getThem(){
var list1 = new List<int>();
forEach(var stockVehicle : StockVehicles){
if(stockVehicle.Status == 4) {
list1.add(stockVehicle.Id);
}
}
return list1;
}
</code></pre>
</section>
<section>
<p >What is the significance of the value 4?</p>
<pre class="fragment"><code data-trim data-noescape>
public List<int> getThem(){
var list1 = new List<int>();
forEach(var stockVehicle : StockVehicles){
if(stockVehicle.Status == Blocked) {
list1.add(stockVehicle.Id);
}
}
return list1;
}
</code></pre>
</section>
<section>
<p>How would I use the list being returned?</p>
<pre class="fragment"><code data-trim data-noescape>
public List<int> getThem(){
var blockedVehicleIds = new List<int>();
forEach(var stockVehicle : StockVehicles){
if(stockVehicle.Status == Blocked) {
blockedVehicleIds.add(stockVehicle.Id);
}
}
return blockedVehicleIds;
}
</code></pre>
</section>
<section>
<p>What paradigm am I working on?</p>
<pre class="fragment"><code data-trim data-noescape>
public List<int> getThem(){
var blockedVehicleIds = new List<int>();
forEach(var stockVehicle : StockVehicles){
if(stockVehicle.isBlocked()) {
blockedVehicleIds.add(stockVehicle.Id);
}
}
return blockedVehicleIds;
}
</code></pre>
</section>
<section>
<p>Could be this code close to that ordinary written prose?</p>
<pre class="fragment"><code data-trim data-noescape>
public List<int> getThem(){
StockVehicles
.Where(vehicle => vehicle.isBlocked())
.Select(vehicle => vehicle.Id)
.ToList();
}
</code></pre>
</section>
</section>
<section>
<h3><b>Simplicity</b></h3>
<p>Eliminating excess complexity enables those reading, using, and modifiying programs to understand them more quickly.</p>
<p class="fragment" style="color: rgb(128, 85,196)">Essential vs accidental complexity</p>
</section>
<section>
<section>
<h3><b>Simplicity</b></h3>
<p>Sometimes, however, I find a simplication that would make a program harder to understand. I choose <span style="color: rgb(128, 85,196)">communication over simplicity</span> in these cases.</p>
</section>
<section>
<p>Why the expected result is 49.25?</p>
<pre><code data-trim data-noescape>
bank.addRate("USD", "GBP", rate);
bank.commission(commission);
Money result = bank.convert(new Note(100, "USD"), "GBP");
assertEquals(new Note(49.25, "GBP"), result);
</code></pre>
</section>
<section>
<p>Be explicit, although a bit of coupling maybe is the comparative cost</p>
<pre><code data-trim data-noescape>
bank.addRate("USD", "GBP", rate);
bank.commission(commission);
Money result = bank.convert(new Note(100, "USD"), "GBP");
assertEquals(new Note(100 / rate
* (1 - commission, "GBP"), result);
</code></pre>
</section>
<section>
<p>Turning it into a property based test, increase the benefits</p>
<pre><code data-trim data-noescape>
forAll(doublesGreaterThan(0)) { rate ->
forAll(doublesGreaterThan(0)) { commission ->
bank.addRate(USD, GBP, rate);
bank.commission(commission);
assertThat(bank.convert(Note(100, USD), GBP),
equalTo(Note(100 / rate * (1 - commission), GBP)))
}
}
</code></pre>
</section>
</section>
<section>
<section>
<h3><b>Simplicity</b></h3>
<p>Simplicity is in the eye of the beholder. What is simple to an expert programmer, <span style="color: rgb(128, 85,196)">familiar</span> with the power tools of the craft, might be overwhelmingly complex to a beginner.</p>
</section>
<section>
<p>Simplicity, familiarity</p>
<pre><code data-trim data-noescape>
public List<int> getThem(){
StockVehicles
.Where(vehicle => vehicle.isBlocked())
.Select(vehicle => vehicle.Id)
.ToList();
}
</code></pre>
</section>
<section>
<p>Simplicity, familiarity</p>
<pre><code data-trim data-noescape>
public List<int> getThem(){
var blockedVehicleIds = new List<int>();
forEach(var stockVehicle : StockVehicles){
if(stockVehicle.isBlocked()) {
blockedVehicleIds.add(stockVehicle.Id);
}
}
return blockedVehicleIds;
}
</code></pre>
</section>
</section>
<section>
<h3><b>Flexibility</b></h3>
<p>Design for the future. Change is expensive. Make it cheap by anticipating it.</p>
<p class="fragment">
<img src="wrong1.gif" width="300px"/>
<img src="wrong2.gif" width="360px"/>
</p>
</section>
<section>
<h3><b>Flexibility</b></h3>
<p>Flexibility is the justification used for the most ineffective coding and design practices.</p>
<p class="fragment">Flexibility can come at the cost of increased complexity.</p>
</section>
<section>
<section>
<h3><b>Flexibility</b></h3>
<p><a href="https://medium.com/@antoniojesussg96/implementando-nuestro-propio-motor-de-reglas-java-da7c778ff1f7">Fizz Buzz Kata with engine rules</a></p>
</section>
<section>
<p><img src="fizzBuzzKataRuleEngine.png" width="200%" /></p>
</section>
</section>
<section>
<h3><b>Flexibility</b></h3>
<blockquote>“That's why flexibility of simplicity and extensive tests is more effective that the flexibility offered by speculated design.”</blockquote>
</section>
<section>
<h3><b>Flexibility</b></h3>
<blockquote>“Paradox, by not considering the future of your code you make your code much more likely to be adaptable in the future”</blockquote>
</section>
<section>
<h3><b>Principles</b></h3>
<ul>
<li>Local consequences</li>
<li>Minimize Repetition</li>
<li>Logic and Data Together</li>
<li>Declarative Expression</li>
<li>Symmetry</li>
<li>Rate of Change</li>
</ul>
<p></p>
</section>
<section>
<h3><b>Local consequences</b></h3>
<p>If a change here can cause a problem there, then the cost of change rise dramatically</p>
<p class="fragment">Code with mostly local consequences communicates effectively. It can be understood gradually without first having assemble an understanding of whole</p>
</section>
<section>
<h3><b>Minimize Repetition</b></h3>
<p>When you have the same code in several places, if you change one copy of the code you have to decide whether or not to change all the other copies</p>
</section>
<section>
<h3><b>Logic and Data Together</b></h3>
<p>Put logic and data it operates on near each other</p>
</section>
<section>
<section>
<h3><b>Declarative Expression</b></h3>
<p>Express the logic describing the What you want to do and not How you want to do.</p>
</section>
<section>
<p>Imperative expression</p>
<pre><code data-trim data-noescape>
List<int> results = new List<int>();
foreach(var num in collection)
{
if (num % 2 != 0)
results.Add(num);
}
</code></pre>
</section>
<section>
<p>Declarative expression</p>
<pre><code data-trim data-noescape>
var results = collection.Where( num => num % 2 != 0);
</code></pre>
</section>
</section>
<section>
<section>
<h3><b>Symmetry</b></h3>
<p>Symmetry in code is where the same idea is expressed the same way everywhere it appears in the code.</p>
<p class="fragment">Once readers understand one half of the simmetry, they can quickly understand the other half.</p>
</section>
<section>
<p></p>
<h3><b>Symmetry</b></h3>
<pre><code data-trim data-noescape>
array_map("process", array(1,2,3));
array_filter(array(1,2,3), "process");
</code></pre>
</section>
<section>
<p></p>
<h3><b>Symmetry</b></h3>
<pre><code data-trim data-noescape>
offer.assignCustomer(customer);
offer.status = Offer.Accepted;
offer.changeLastModifiedDate();
</code></pre>
</section>
<section>
<p></p>
<h3><b>Symmetry</b></h3>
<pre><code data-trim data-noescape>
offer.assignCustomer(customer);
offer.accept();
offer.changeLastModifiedDate();
</code></pre>
</section>
<section>
<p></p>
<h3><b>Symmetry, preliminary step to removing duplication</b></h3>
<pre><code data-trim data-noescape>
offer.assignCustomer(customer);
offer.accept();
</code></pre>
</section>
</section>
<section>
<section>
<h3><b>Rate of change</b></h3>
<p>Put logic or data that changes at the same rate together and separate logic or data that changes at different rates</p>
</section>
<section>
<p>Change together</p>
<pre><code data-trim data-noescape>
public void setAmount(int value, string currency){
this.value = value;
this.currency = currency;
}
</code></pre>
</section>
<section>
<p>Becomes</p>
<pre><code data-trim data-noescape>
public void setAmount(Money value){
this.value = value;
}
</code></pre>
</section>
</section>
<section>
<section>
<h3><b>Remember!</b></h3>
</section>
<section>
<h3><b>Communication, Simplicity & Flexibility</b></h3>
<ul>
<li>Local consequences</li>
<li>Minimize Repetition</li>
<li>Logic and Data Together</li>
<li>Declarative Expression</li>
<li>Symmetry</li>
<li>Rate of Change</li>
</ul>
<p></p>
</section>
<section>
<h3><b>Remember!</b></h3>
<blockquote>“Programming, then, is a human task done by humans for humans.”</blockquote>
<p>Kent Beck</p>
</section>
</section>
<section>
<p><img src="theEnd.gif"/></p>
<p><img src="cas2017.png" width="300"/></p>
</section>
<section>
<h3>Related links</h3>
<p>
<a href="https://www.goodreads.com/book/show/781559.Implementation_Patterns">Implementation Patterns Book</a>
</p>
<p>
<a href="https://www.infoq.com/presentations/Simple-Made-Easy">Simple Made Easy - Rich Hickey</a>
</p>
<p>
<a href="https://www.youtube.com/watch?v=wn_z9aV3Kzo">Economía del software en 10 min - Artola & Guillermo</a>
</p>
<p>
<a href="https://gist.github.com/franreyes/44b14720a4f32800df9cafee11e320ed">Communication over simpliflication example (Property based testing contribution by Nat Pryce)</a>
</p>
<p>
<a href="https://www.youtube.com/watch?v=6FDxbCzh2sI">Simplicidad para desarrolladores - Eduardo Ferro</a>
</p>
<p>
<a href="https://dannorth.net/2011/01/31/whose-domain-is-it-anyway/">Chunking or the myth of declarative - Dan North</a>
</p>
<p>
<a href="https://www.codesai.com/2017/01/an-example-of-introducing-symmetry-to">An example of introducing symmetry to enable duplication removal - Manuel Rivero</a>
</p>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<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, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
</body>
</html>