/
index.html
1049 lines (1002 loc) · 38.6 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
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Eating ElePHPants</title>
<meta name="author" content="Larry Garfield">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="palantirnet-theme/css/styles.css" id="theme">
<!-- 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 ) ? 'palantirnet-theme/css/print/pdf.css' : 'palantirnet-theme/css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
<style type="text/css">
dl dt {
text-align: left;
}
dl dd {
margin-left: 2em;
text-align: left;
}
.struck {
text-decoration: line-through;
}
li.bigdeal {
font-size: 150%;
color: Red;
font-style: italic;
text-shadow: 3px 3px 10px #990000;
}
p.bigdeal {
font-size: 200%;
color: Red;
font-style: italic;
text-shadow: 3px 3px 10px #990000;
}
</style>
<script src="palantirnet-theme/js/classer.js"></script>
</head>
<!-- Change body class to "dark" if you prefer a dark theme, or "light" if you'd rather have a light theme-->
<body class="light">
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h1>Eating ElePHPants</h1>
<p>
<small>Presented by <a href="http://www.garfieldtech.com/">Larry Garfield</a> (<a href="http://twitter.com/Crell">@Crell</a>)</small>
</p>
</section>
<section class="l-2up">
<h2><a href="http://twitter.com/Crell">@Crell</a></h2>
<div>
<img src="assets/larry-olaf-hug.jpg" alt="Larry implements Huggable" style="width: 350px; margin: 0" />
</div>
<div>
<ul style="text-wrap: none">
<li>Senior Architect, <a href="http://www.palantir.net/">Palantir.net</a></li>
<li style="margin-top: 1em;">Drupal 8 Web Services Lead</li>
<li style="margin-top: 1em;">Drupal Representative, <a href="http://www.php-fig.org/">PHP-FIG</a></li>
<li style="margin-top: 1em;">Advisor, Drupal Association</li>
<li style="margin-top: 1em;"><code>implements Huggable</code></li>
</ul>
</div>
</section>
<section>
<section data-background="assets/duplo-kids.jpg" data-credit="https://www.flickr.com/photos/ianus/9373214">
<aside class="notes">
Who's excited to write code like this?
</aside>
</section>
<section data-background="assets/spaghetti.jpg" data-credit="https://www.flickr.com/photos/hatm/5704123809">
<aside class="notes">
Going home to this?
</aside>
</section>
</section>
<section>
<section>
<p class="bigtext">Evolution is possible!</p>
</section>
<section>
<p class="bigtext">Target Testable Code</p>
<aside class="notes">
<ul>
<li>"In what direction do we evolve?" Toward testability</li>
</ul>
</aside>
</section>
<section>
<p class="bigtext">"Testable" is a proxy for ...</p>
<ul class="fragment">
<li>Loosely coupled</li>
<li>Decoupled</li>
<li>Injectable</li>
<li>Reusable</li>
<li>Understandable</li>
<li>Clean</li>
<li>"Good"</li>
</ul>
<p class="fragment bigtext" style="margin-top: 1em;">If it's hard to test, <em>you're doing it wrong</em></p>
<aside class="notes">
<ul>
<li>Testability is a stand-in for "good".</li>
<li>Semantic markup ~ SEO ~ Accessibility</li>
</ul>
</aside>
</section>
<section>
<div class="l-2up">
<img src="assets/drupal-7-logo.jpg" style="height: 200px;" alt="Drupal 7" data-credit="https://association.drupal.org/files/drupal-7-logo.jpg" />
<ul style="text-wrap: none">
<li class="fragment">PHP4-era Procedural</li>
<li class="fragment">Array-oriented</li>
<li class="fragment">Lots of functional tests</li>
<li class="fragment">"Idiomatic" (but extensible) architecture</li>
<li class="fragment">Runs 2% of the web</li>
<li class="fragment">Massive community (954 contributors)</li>
</ul>
</div>
<p style="clear: both; margin-top: 2em;" class="fragment">Very powerful, but straining at the seams</p>
</section>
<section>
<div class="l-2up">
<img src="assets/drupal-8-logo.png" style="height: 200px;" alt="Drupal 8" data-credit="https://drupal.org/node/2119739" />
<ul>
<li class="fragment">Architecturally OOP</li>
<li class="fragment">8506 unit tests (and counting)</li>
<li class="fragment">Flexible architecture</li>
<li class="fragment">Modern standards</li>
<li class="fragment">Embraces PIE</li>
<li class="fragment">>3x contributors (3136 and counting)</li>
</ul>
</div>
<p style="clear: both; margin-top: 2em;" class="fragment">How'd they do that?</p>
</section>
<section>
<h3>How does one eat an elePHPant?</h3>
<img src="assets/eat-elephpant.jpg" style="width: 80%" alt="How do you eat an elephpant?" />
</section>
<section>
<h3>One bite at a time...</h3>
<img src="assets/eat-elephpants-mini.jpg" style="width: 80%" alt="One bite at a time" />
</section>
<section>
<h3>... with friends</h3>
<img src="assets/eat-elephpants-friends.jpg" style="width: 80%" alt="With friends" />
</section>
<section>
<h3>… with <em>lots</em> of friends</h3>
<img src="assets/drupalcon-portland.jpg" style="width: 80%" alt="DrupalCon Portland" />
</section>
<section>
<h2>WSCCI</h2>
<p class="fragment">Web Services and Context Core Initiative</p>
<blockquote class="fragment">Drupal needs to evolve, and quickly, from a
first-class web CMS into a first-class REST server that includes a
first-class web CMS.</blockquote>
</section>
<section>
<p>Refactoring everything wasn't a goal, it was a methodology</p>
<aside class="notes">
<ul>
<li>Wanted to do the new stuff "the right way" for its own sake</li>
<li>Let it ripple out as it would</li>
<li>We can't be the first to do this...</li>
</ul>
</aside>
</section>
<section>
<img src="assets/drufony.png" alt="Drupal + Symfony = Drufony" style="max-height: 500px;" />
<aside class="notes">
<ul>
<li>HttpFoundation first, then Kernel, then snowball</li>
</ul>
</aside>
</section>
<section>
<h2>Proudly Invented Elsewhere</h2>
<ul class="fragment">
<li>Symfony2 <small>(HttpFoundation, HttpKernel, DependencyInjection, EventDispatcher, Routing, Serializer, Validator, Yaml)</small></li>
<li>Symfony CMF</li>
<li>Zend Feed</li>
<li>Doctrine Annotations</li>
<li>Guzzle</li>
<li>EasyRDF</li>
<li>Twig</li>
<li>PHPUnit</li>
<li>Zend Diactoros</li>
</ul>
</section>
<section>
<p class="bigtext">Learn from our <span id="our-experience">experience</span> <span class="fragment" data-classer="our-experience" data-classer-class="struck">mistakes</span></p>
</section>
<section>
<p class="bigtext">Refactoring is more a social/governance<br />challenge than a technical challenge</p>
<aside class="notes">
<ul>
<li>True of OSS and company development</li>
<li>Leadership buy-in needed</li>
<li>Subterfuge possible, short-lived</li>
</ul>
</aside>
</section>
</section>
<section>
<section>
<blockquote>Plans are worthless, but planning is everything.</blockquote>
<p>—Dwight Eisenhower</p>
</section>
<section>
<p class="bigtext">Are you refactoring<br />or adding refactored features?</p>
<aside class="notes">
<ul>
<li>Drupal wanted features; new-style was means to end</li>
<li>Some people taken by surprise by refactoring</li>
<li>Refactoring for its own sake came later</li>
</ul>
</aside>
</section>
<section>
<p>People need to see value</p>
<p class="fragment">Developers need to see value</p>
<p class="fragment">Management need to see value</p>
<aside class="notes">
<ul>
<li>Drupal has management; Dries, Angie, companies, etc.</li>
<li>You need buy-in</li>
</ul>
</aside>
</section>
<section>
<p class="bigtext">Is refactoring valuable?</p>
</section>
<section>
<p><q>Code quality doesn't matter, only user experience matters</q></p>
<p id="dx-wrong" class="fragment " data-classer="dx-wrong" data-classer-class="bigdeal" style="margin-top: 1em;">Wrong</p>
<p class="fragment" style="margin-top: 2em;">Developers are users... <span class="fragment">of code</span></p>
<aside class="notes">
<ul>
<li>UX depends on developer's ability to implement; bad code, no implementation</li>
<li>Technical debt limits ability to develop</li>
</ul>
</aside>
</section>
<section>
<p style="text-align: left;"><q>The new code will be better</q></p>
<p style="text-align: right; margin-top: 1em;" class="fragment"><q>I'll believe it when I see it</q></p>
</section>
<section>
<h2>The first taste</h2>
<ul>
<li class="fragment">Drupal 7 DBAL</li>
<li class="fragment">Home grown (Sorry, Doctrine)</li>
<li class="fragment">98% OOP</li>
<li class="fragment"><q>See, it's not so scary</q></li>
</ul>
<p style="margin-top: 1em;" class="fragment">c. 2008-2011</p>
<aside class="notes">
<ul>
<li>Very successful; way easier for devs than manual</li>
</ul>
</aside>
</section>
<section>
<h2>The big bite</h2>
<ul>
<li class="fragment">Routing / Web services</li>
<li class="fragment">REST-ify routing</li>
<li class="fragment">Lots of Symfony code</li>
</ul>
<p class="fragment" style="margin-top: 1em;"><q>Throw HttpKernel in the middle<br />and let the chips fall where they may</q></p>
<aside class="notes">
<ul>
<li>Old router only knew paths</li>
<li>Symfony/CMF router knows full request</li>
<li>The world didn't need another Request object</li>
</ul>
</aside>
</section>
<section>
<p class="bigtext">Make the old code feel clunkier<br />in comparison</p>
</section>
<section>
<p class="bigtext">Shame the old code, not the old coders</p>
<aside class="notes">
<ul>
<li>Half of it was your code anyway</li>
<li>You want friends helping, not fighting you</li>
</ul>
</aside>
</section>
<section>
<h2>Bottom up</h2>
<div class="l-2up">
<div class="fragment">
<h3 style="text-align: center">Pros</h3>
<ul>
<li class="fragment">Low-hanging fruit</li>
<li class="fragment">Easier parallelism</li>
<li class="fragment">Unravel knots bit by bit</li>
</ul>
</div>
<div class="fragment">
<h3 style="text-align: center">Cons</h3>
<ul>
<li class="fragment">Low-incentive</li>
<li class="fragment">Less impactful</li>
<li class="fragment">Staving off the big break</li>
</ul>
</div>
</div>
</section>
<section>
<h2>Top down</h2>
<div class="l-2up">
<div class="fragment" style="float: left; width: 48%">
<h3 style="text-align: center">Pros</h3>
<ul>
<li class="fragment">Highest-visibility first</li>
<li class="fragment">Identify the major knots</li>
<li class="fragment">Better contrast w/ old code</li>
</ul>
</div>
<div class="fragment" style="float: right; width: 48%">
<h3 style="text-align: center">Cons</h3>
<ul>
<li class="fragment">Higher risk</li>
<li class="fragment">So many knots…</li>
<li class="fragment">Don't forget the low-fruit!</li>
</ul>
</div>
</div>
<aside class="notes">
<ul>
<li>High risk = Not enough experience yet.</li>
<li>low-fruit: drupal_set_message() is still a function. WTF?</li>
</ul>
</aside>
</section>
<section>
<blockquote>The right approach technically<br />and the right approach politically<br />may be completely different.</blockquote>
</section>
<section>
<p class="bigtext">Clear messaging</p>
</section>
<section>
<p class="bigtext">Repeat your message</p>
<p class="fragment">Everyone wants to hear the message themselves</p>
<p class="fragment">Need to repeat it in different ways</p>
<p class="fragment">It's a total waste of time... <span class="fragment">Do it anyway</span></p>
<aside class="notes">
<ul>
<li>Blogs, IRC, pub. discussions, conferences</li>
<li>Took a year for people to stop asking "so what is WSCCI?"</li>
<li>Politicians sound like canned responses because they are canned</li>
</ul>
</aside>
</section>
<section>
<p class="bigtext">There are costs to poor messaging...</p>
<ul>
<li class="fragment">People learn at different rates</li>
<li class="fragment">You're moving my cheese!</li>
<li class="fragment">Not everyone will make the transition...</li>
</ul>
<aside class="notes">
<ul>
<li>Extreme cases, fork; Backdrop</li>
<li>Will you get more people than you lose? I think yes.</li>
</ul>
</aside>
</section>
</section>
<section>
<section>
<blockquote>Amateurs think about tactics,<br />but professionals think about logistics.</blockquote>
<p>—General Robert H. Barrow, US Marine Corps</p>
</section>
<section>
<blockquote>Give me 5 people 10 hours a week and I can do anything. Give me 50 people one hour a week and I can't do squat.</blockquote>
<p>—Larry Garfield, 2011 <span class="fragment">and 2012</span> <span class="fragment">and 2013</span> <span class="fragment">and 2014</span></p>
<p class="bigtext fragment" style="margin-top: 1em;">Work does not happen in spare time</p>
<aside class="notes">
<ul>
<li>"In-house projects" happen when?</li>
<li>Nights and weekends SUCK.</li>
<li>Meetings 1 hour increments; work 4 hour increments</li>
</ul>
</aside>
</section>
<section>
<h3>Sprints</h3>
<ul>
<li class="fragment"><em>In person</em> collaboration</li>
<li class="fragment"><em>Small</em> group</li>
<li class="fragment"><em>Right</em> people</li>
<li class="fragment"><em>Dedicated</em> time</li>
</ul>
<div class="fragment">
<blockquote>"if you give 3 people 3 days to work together on something, they’ll get unbelievable amounts of work done."</blockquote>
<p>— Tim Plunkett, Drupal 8 developer #2</p>
</div>
<aside class="notes">
<ul>
<li>Drupal one of the largest distrib teams in the world</li>
<li>We work best in person</li>
</ul>
</aside>
</section>
<section>
<p class="bigtext">Beware the bikeshed</p>
</section>
<section>
<img src="assets/nuclear-reactor-control.jpg" alt="Nuclear reactors are complicated" data-credit="https://www.flickr.com/photos/martinpro/2138123729" />
</section>
<section>
<img src="assets/bikeshed.jpg" alt="Bikesheds are dangerous places" data-credit="https://www.flickr.com/photos/simonsmithster/3418651078" />
</section>
<section>
<h3>Configuration system</h3>
<ul>
<li class="fragment">Feature change #1</li>
<li class="fragment">Staging & Deployment: Solved!</li>
<li class="fragment">June 2011: 3 day, 5 person sprint, Denver</li>
<li class="fragment">Detailed recommendation</li>
<li class="fragment">Files on disk, load system, API, staging, etc.</li>
<li class="fragment" id="cmi-format-list">Format: JSON, YAML, XML?</li>
</ul>
<span class="fragment" data-classer="cmi-format-list" data-classer-class="bigdeal"></span>
</section>
<section>
<img src="assets/picard-riker-facepalm.jpg" alt="Picard-Riker Face Palm" />
<aside class="notes">
<ul>
<li>Eventually JSON, because easy</li>
<li>Moved to YAML, because docs/UTF-8</li>
<li>XML would have been better long-run, but too much hate</li>
</ul>
</aside>
</section>
<section>
<h3>Bikeshed stoppers</h3>
<ul>
<li class="fragment">Strong leadership</li>
<li class="fragment">Clear decision making process</li>
<li class="fragment">Over-communication</li>
</ul>
<p class="fragment bigtext">Luck</p>
<aside class="notes">
<ul>
<li>Strong leaders know how/when to say Shut Up in a way people appreciate</li>
<li>Explain reasons behind everything</li>
<li></li>
<li>So now that you're doing it, how do you do it, tactically?</li>
</ul>
</aside>
</section>
</section>
<section>
<section>
<blockquote>Proper prior planning prevents piss poor performance</blockquote>
<p>—<a href="http://en.wikipedia.org/wiki/7_Ps_%28military_adage%29">British military adage</a></p>
</section>
<section>
<p class="bigtext">Don't write unit tests</p>
</section>
<section>
<h2>Say WAT?</h2>
<img src="assets/chris-hartjes-grumpy-cropped.jpg" alt="Grumpy does not approve!" style="width: 50%;" data-credit="https://www.flickr.com/photos/akrabat/8421560178/" />
</section>
<section>
<h2>Write system tests</h2>
<ul>
<li class="fragment">If your code were already unit testable we'd be done</li>
<li class="fragment">Unit tests change with the unit</li>
<li class="fragment">Unit test the new stuff</li>
<li class="fragment">Don't break <em>user</em> functionality</li>
<li class="fragment">100% green at all times</li>
</ul>
</section>
<section>
<p>Drupal wrote its own testing framework</p>
<p class="fragment">(Hey, it was 2008)</p>
<p class="fragment">Having those tests saved our butts</p>
<p style="margin-top: 1em;">
<img class="fragment" src="assets/behat-logo.png" alt="Behat" style="background: lightgray;" />
<img class="fragment" src="assets/selenium-logo.png" alt="Selenium" />
</p>
<aside class="notes">
<ul>
<li>Pre-Travis et al</li>
<li>Pre-Behat</li>
</ul>
</aside>
</section>
<section>
<p>Functional tests are for functionality... only</p>
<p class="fragment">Pseudo-unit tests are worse than no tests</p>
</section>
<section>
<p class="bigtext">Sharing is caring</p>
</section>
<section>
<p style="text-align: left;"><q>I don't want to maintain [my] crappy code!</q></p>
<p style="text-align: right; margin-top: 1em;" class="fragment"><q>So use someone else's</q></p>
<p class="fragment" style="margin-top: 1em;">(Then they have to maintain it!)</p>
<aside class="notes">
<ul>
<li>Composer, Symfony, Zend, Aura: Components FTW!</li>
<li>Systems not built from components suck; replace them</li>
</ul>
</aside>
</section>
<section>
<img src="assets/osi-symbol.png" style="width: 50%;" alt="The logo of the Open Source Initiative" data-credit="http://opensource.org/" />
<h3>That's the point</h3>
</section>
<section>
<h3>For new functionality</h3>
<div class="fragment">
<blockquote>Writing code should not be the 1st response. Finding if shared code exists should be the 1st response.</blockquote>
<p>— <a href="https://twitter.com/e3BethT/status/457207489851686913">Beth Tucker-Long</a></p>
</div>
<p class="fragment" style="margin-top: 1em;">Drupal never seriously considered writing a YAML parser</p>
<aside class="notes">
<ul>
<li>New Configuration system, uses YAML</li>
<li>Uses Symfony YAML</li>
</ul>
</aside>
</section>
<section>
<h3>Share with yourself</h3>
<ul>
<li class="fragment">Build new code as components</li>
<li class="fragment">Write it right</li>
<li class="fragment">Share on Packagist!</li>
</ul>
<aside class="notes">
<ul>
<li>\Drupal\Component</li>
<li>Keeping it in sep package forces decoupling</li>
<li>Drupal Components hard to keep clean</li>
</ul>
</aside>
</section>
<section>
<h3>For existing functionality</h3>
<p class="fragment" style="margin-top: 1em;">Refactor your app, don't replace it</p>
<p class="fragment">Replace your component, don't refactor it</p>
</section>
<section>
<h3><code id="dhr">drupal_http_request()</code></h3>
<ul>
<li class="fragment">HTTP/1.0 client</li>
<li class="fragment">One 304 line function <span class="fragment">(No, really)</span></li>
<li class="fragment">N-Path complexity: 25,303,344,960</li>
<li class="fragment">Lacking a number of features (proxy support)</li>
</ul>
<div class="fragment" data-classer="dhr" data-classer-class="struck" style="margin-top: 1em;">
<img src="assets/guzzle-logo.png" style="background: #344041; width: 200px" alt="Guzzle logo" />
<p><code>s/drupal_http_request()/Guzzle/</code></p>
</div>
<aside class="notes">
<ul>
<li>Guzzle 3 refactored FOR US</li>
</ul>
</aside>
</section>
<section>
<h2>However!</h2>
<p class="bigtext fragment">If it's not broke, don't fix it</p>
<aside class="notes">
<ul>
<li>Outsourcing has costs; lack of control</li>
<li>It often has value... but not always</li>
<li>Still using own DBAL</li>
</ul>
</aside>
</section>
<section>
<img src="assets/automate-all-the-things.jpg" alt="Automate all the things!" />
</section>
<section>
<p style="text-align: left;">You want 100% green tests?</p>
<p style="text-align: right;" class="fragment">CI server or it won't happen</p>
<aside class="notes">
<ul>
<li>Testbot sucks, but it saves our butt daily.</li>
<li>Travis?</li>
</ul>
</aside>
</section>
<section>
<h3>Performance</h3>
<div class="fragment">
<blockquote>When you commit enough regressions, it gets harder to measure new ones.</blockquote>
<p>—Nathaniel Catchpole (catch), Drupal 8 Release Manager</p>
</div>
<aside class="notes">
<ul>
<li>OOP code isn't slower</li>
<li>Refactoring can break performance</li>
</ul>
</aside>
</section>
</section>
<section>
<section>
<blockquote>The Best is the Enemy of Good</blockquote>
<p>—My dad <span class="fragment">(and Voltaire)</span></p>
</section>
<section>
<p class="bigtext">Idealism is a guide, not a rule</p>
</section>
<section>
<p class="bigtext">Incremental progress is progress</p>
<aside class="notes">
<ul>
<li>Hard to remember when you don't know when your deadline is.</li>
</ul>
</aside>
</section>
<section>
<p class="bigtext">User a Service Locator</p>
</section>
<section>
<h3>Larry, you so funny...</h3>
<img src="assets/paul-jones-laugh.jpg" alt="Paul Jones is amused!" style="width: 60%;" data-credit="https://www.flickr.com/photos/sebastian_bergmann/1437573772" />
</section>
<section>
<p><q>But Service Locators are eeeeevil!</q></p>
<p class="fragment">Service Locator = passed DI Container</p>
<p class="fragment">That's it</p>
</section>
<section>
<p>Remember what we said about small steps?</p>
<img src="assets/eat-elephpants-mini.jpg" style="width: 80%" alt="One bite at a time" />
<aside class="notes">
<ul>
<li>An SL is better than functions</li>
<li>One global is better than many</li>
</ul>
</aside>
</section>
<section>
<pre class="font--20"><code class="php" data-trim>
class Drupal {
protected static $container;
public static function setContainer(ContainerInterface $container = NULL) {
static::$container = $container;
}
public static function getContainer() {
return static::$container;
}
public static function service($id) {
return static::$container->get($id);
}
public static function entityManager() {
return static::$container->get('entity.manager');
}
// ...
}
</code></pre>
<aside class="notes">
<ul>
<li>Only one global</li>
<li>For procedural code only!</li>
</ul>
</aside>
</section>
<section>
<pre class="font--20"><code class="php" data-trim>
function menu_menu_update(Menu $menu) {
menu_cache_clear_all();
// Invalidate the block cache to update menu-based derivatives.
if (\Drupal::moduleHandler()->moduleExists('block')) {
\Drupal::service('plugin.manager.block')->clearCachedDefinitions();
}
}
</code></pre>
<aside class="notes">
<ul>
<li>Still ugly, but the code it calls doesn't have to be.</li>
</ul>
</aside>
</section>
<section>
<pre class="font--20"><code class="php" data-trim>
class BookManager {
public function bookTreeAllData($bid, $link = NULL, $max_depth = NULL) {
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
// ...
$tree[$cid] = $this->bookTreeBuild($bid, $tree_parameters);
return $tree[$cid];
}
}
</code></pre>
<aside class="notes">
<ul>
<li>No injection, legacy procedural code</li>
</ul>
</aside>
</section>
<section>
<pre class="font--20"><code class="php" data-trim>
class BookManager {
public function bookTreeAllData($bid, $link = NULL, $max_depth = NULL) {
$language_interface = $this->languageManager()->getCurrentLanguage();
// ...
$tree[$cid] = $this->bookTreeBuild($bid, $tree_parameters);
return $tree[$cid];
}
public function languageManager() {
return \Drupal::languageManager();
}
}
</code></pre>
<aside class="notes">
<ul>
<li>Now just need to inject and change languageManager()</li>
</ul>
</aside>
</section>
<section>
<pre class="font--20"><code class="php" data-trim>
class BookManager {
public function __construct(LanguageManager $language_manager) {
$this->languageManager = $language_manager
}
public function bookTreeAllData($bid, $link = NULL, $max_depth = NULL) {
$language_interface = $this->languageManager()->getCurrentLanguage();
// ...
$tree[$cid] = $this->bookTreeBuild($bid, $tree_parameters);
return $tree[$cid];
}
public function languageManager() {
return $this->languageManager;
}
}
</code></pre>
<aside class="notes">
<ul>
<li>And we're done.</li>
</ul>
</aside>
</section>
<section>
<p>Service locators are a stepping stone<br />toward Dependency Injection</p>
</section>
<section>
<h3>Break things in steps</h3>
<ul>
<li class="fragment">BC shims are your friend</li>
<li class="fragment">Deprecate immediately</li>
<li class="fragment">Convert BC shims</li>
</ul>
<aside class="notes">
<ul>
<li>BC shim = Backward compatibility layer</li>
<li>Old func calls the new func</li>
</ul>
</aside>
</section>
<section>
<p><q>Nothing is more permanent than a temporary solution</q></p>
<p class="fragment" style="margin-top: 1em;">This takes commitment to address</p>
</section>
<section>
<h3>Temporary solutions</h3>
<ul>
<li class="fragment"><code>@deprecated</code> <span class="fragment" style="font-style: italic;">(Never add uses)</span></li>
<li class="fragment">Change notices (and Documentation!)</li>
<li class="fragment">Peer review</li>
<li class="fragment"><code>E_USER_DEPRECATED</code>?</li>
<li class="fragment">Sunset plan: <span class="fragment">release blocking?</span></li>
</ul>
</section>
<section>
<p>Changesets that just remove legacy use<br /><em>must</em> be acceptable</p>
<p class="fragment" style="margin-top: 1em;">Improving code without adding features <em>must</em> be acceptable</p>
<p class="fragment" style="margin-top: 1em;">Time for just paying down debt <em>must</em> be acceptable</p>
<aside class="notes">
<ul>
<li>Rearranging deck chairs on the Titanic is OK if they get you closer to a life boat</li>
<li>Early: "No new features, so why do it?" -- Slowed us down a lot</li>
<li>Code improvement has to be seen as intrinsically valuable</li>
<li>Management problem if not...</li>
</ul>
</aside>
</section>
<section>
<p class="bigtext">Don't bite off more than you can chew</p>
</section>
<section>
<h3>Session handling</h3>
<ul>
<li class="fragment">2 years on 1 patch... fail :-(</li>
<li class="fragment">Incremental steps: 10+ patches…</li>
<li class="fragment">… across 18 months</li>
</ul>
<p class="fragment">Finally!</p>
</section>
<section>
<p><q>Procedural code inside class keyword is still progress</q></p>
</section>
<section>
<h3>Form Builder</h3>
<pre class="font--20"><code class="php" data-trim>
class FormBuilder {
public function __construct(FormValidatorInterface $form_validator, FormSubmitterInterface $form_submitter, FormCacheInterface $form_cache, ModuleHandlerInterface $module_handler, EventDispatcherInterface $event_dispatcher, RequestStack $request_stack, ClassResolverInterface $class_resolver, ElementInfoManagerInterface $element_info, ThemeManagerInterface $theme_manager, CsrfTokenGenerator $csrf_token = NULL) {
$this->formValidator = $form_validator;
$this->formSubmitter = $form_submitter;
$this->formCache = $form_cache;
$this->moduleHandler = $module_handler;
$this->eventDispatcher = $event_dispatcher;
$this->requestStack = $request_stack;
$this->classResolver = $class_resolver;
$this->elementInfo = $element_info;
$this->csrfToken = $csrf_token;
$this->themeManager = $theme_manager;
}
// ...
public function getFormId($form_arg, &$form_state) {
// 20 lines of fugly here.
}
public function buildForm($form_id, array &$form_state) {
// 100 lines of code/comments here
return $form;
}
}
</code></pre>
<aside class="notes">
<ul>
<li>10 dependencies(!)</li>
</ul>
</aside>
</section>
<section>
<h3>form.inc</h3>
<pre class="font--20"><code class="php" id="procedural-form-api" data-trim>
/**
* @deprecated
*/
function drupal_get_form($form_arg) {
return call_user_func_array(
[\Drupal::formBuilder(), 'getForm'],
func_get_args()
);
}
/**
* @deprecated
*/
function drupal_build_form($form_id, &$form_state) {
return \Drupal::formBuilder()->buildForm($form_id, $form_state);
}
/**
* @deprecated
*/
function form_state_defaults() {
return \Drupal::formBuilder()->getFormStateDefaults();
}
</code></pre>
<p style="margin-top: 1em;" class="fragment">Later removed entirely!</p>
</section>
<section>
<p>No program will ever be perfect<span class="fragment">, just make it better</span></p>
<p class="fragment" style="margin-top: 1em;">Contain the crap</p>
<aside class="notes">
FormBuilder is gross, but injectable
</aside>
</section>
<section>
<h3>Form Builder</h3>
<pre class="font--20"><code class="php" data-trim>
class FormBuilder {
public function __construct(FormValidatorInterface $form_validator, FormSubmitterInterface $form_submitter, FormCacheInterface $form_cache, ModuleHandlerInterface $module_handler, EventDispatcherInterface $event_dispatcher, RequestStack $request_stack, ClassResolverInterface $class_resolver, ElementInfoManagerInterface $element_info, ThemeManagerInterface $theme_manager, CsrfTokenGenerator $csrf_token = NULL) {
$this->formValidator = $form_validator;
$this->formSubmitter = $form_submitter;
$this->formCache = $form_cache;
$this->moduleHandler = $module_handler;
$this->eventDispatcher = $event_dispatcher;
$this->requestStack = $request_stack;
$this->classResolver = $class_resolver;
$this->elementInfo = $element_info;
$this->csrfToken = $csrf_token;
$this->themeManager = $theme_manager;
}
}
</code></pre>
<p class="fragment">The code around it is fine</p>
<aside class="notes">
<ul>
<li>Patches ready and waiting to simplify.</li>
</ul>
</aside>
</section>
<section>
<p>Know when to push for better, and when it's good enough</p>
</section>
<section>
<blockquote>"perfect is the enemy of good". yeah, but good enough is the enemy of good, too.</blockquote>
<p>— <a href="https://twitter.com/getify/status/625321163409874944">@Getify</a></p>
</section>
<section>
<p class="bigtext">Interfaces FTW</p>
<p class="fragment" style="margin-top: 1em;">Refactor the fugly to be smaller</p>
<aside class="notes">
<ul>
<li>Getting to clean interfaces is worth fighting for</li>
<li>Cleaning up implementation is next; sometimes fight</li>
</ul>
</aside>
</section>
</section>
<section>
<h3>This is an ongoing process</h3>
<img class="fragment" src="assets/sisyphus-cat.jpg" alt="Sysyphus cat tries again" data-credit="http://cheezburger.com/887098624" />
</section>
<section>
<h3>One bite at a time, with friends</h3>
<img src="assets/eat-elephpants-friends.jpg" style="width: 80%" alt="With friends" />
</section>
<section>
<img src="assets/druplicon.svg" style="width: 50%" alt="Druplicon" />
<p class="fragment">If we can do it, so can you</p>
</section>
<section id="final-slide">
<h2>Larry Garfield</h2>
<p>Senior Architect, <a href="http://www.palantir.net/">Palantir.net</a></p>
<p>Making the Web a Better Place</p>
<p>Keep tabs on our work at <a href="http://twitter.com/Palantir">@Palantir</a></p>
<p>Want to hear about <a href="http://eepurl.com/ws6uj">what we're doing</a>?</p>
</section>
</div>
<footer class="footer">
<a class="logo-wrapper" href="https://www.palantir.net/" title="Link to Palantir.net's website">
<div class="logo">
<p>Palantir.net</p>
</div>
</a>
</footer>
<div style="display:none">
The story of Drupal:
* D7
* D8
* elephpants
* WSCCI
* Learn from our mistakes
Plan ahead (mgmt):
Mesaging matters (social)
Beachhead (social)
Structure:
* Undivided attention (social)
* Bikeshed (social)