Protocols All The Way Down - dotSwift, Paris, January 2018

C4861b1dfdf3bbb21faec4a1acdf183d?s=47 Ellen Shapiro
January 29, 2018

Protocols All The Way Down - dotSwift, Paris, January 2018

A talk about the benefits and drawbacks of Protocol Oriented Programming, and protocols with default implementations.

Video:
https://www.dotconferences.com/2018/01/ellen-shapiro-protocols-all-the-way-down

Playground:
https://github.com/designatednerd/ProtocolPlayground

C4861b1dfdf3bbb21faec4a1acdf183d?s=128

Ellen Shapiro

January 29, 2018
Tweet

Transcript

  1. PROTOCOLS ALL THE WAY DOWN DOT SWIFT | PARIS, FRANCE

    | JANUARY 2018 @DESIGNATEDNERD | BAKKENBAECK.COM | JUSTHUM.COM
  2. None
  3. PROTOCOL-ORIENTED PROGRAMMING

  4. None
  5. None
  6. PROTOCOL-ORIENTED PROGRAMMING

  7. PROTOCOLS WITH DEFAULT IMPLEMENTATIONS

  8. None
  9. None
  10. None
  11. None
  12. DEFAULT PROTOCOL IMPLEMENTATION extension

  13. None
  14. None
  15. None
  16. None
  17. None
  18. None
  19. None
  20. None
  21. None
  22. None
  23. None
  24. None
  25. None
  26. CONDITIONAL DEFAULT PROTOCOL IMPLEMENTATION extension

  27. None
  28. None
  29. None
  30. None
  31. extension

  32. None
  33. None
  34. None
  35. None
  36. where Self:...

  37. None
  38. None
  39. github.com/designatednerd/ ProtocolPlayground

  40. None
  41. None
  42. None
  43. None
  44. None
  45. None
  46. MULTIPLE where CLAUSES

  47. None
  48. None
  49. None
  50. None
  51. None
  52. None
  53. None
  54. None
  55. None
  56. None
  57. None
  58. None
  59. SUBCLASS-LIKE BEHAVIOR WITHOUT THE BAGGAGE OF SUBCLASSING

  60. CENTRALIZATION! DRY CODE!

  61. NO INSANE INHERITANCE TREES

  62. PROTOCOL-ORIENTED ! PITFALLS

  63. POP QUIZ

  64. None
  65. None
  66. None
  67. None
  68. None
  69. None
  70. None
  71. None
  72. TYPE INFERENCE: !

  73. TYPE INFERENCE: !

  74. TYPE INFERENCE: !

  75. SPECIFYING PROTOCOL TYPE: !

  76. SPECIFYING PROTOCOL TYPE: !

  77. SPECIFYING PROTOCOL TYPE: !

  78. SPECIFYING PROTOCOL TYPE: !

  79. SPECIFYING PROTOCOL TYPE: !

  80. None
  81. None
  82. None
  83. DEFAULT IMPLEMENTATIONS VS. EXTENSIONS VS. SUBCLASSES

  84. DEFAULT IMPLEMENTATIONS **(PLAIN VANILLA OR CONDITIONAL) VS. EXTENSIONS VS. SUBCLASSES

  85. > Do I need this to work on all instances

    and/or subclasses of a particular thing? Extension! > Do I need this method to work only when I say it should, or in a particular combination of circumstances? Default implementation! > Does this always need to be called from a particular lifecycle or delegate method? Subclass!
  86. CHOOSE YOUR TOOLS WISELY

  87. None
  88. ! MERÇI BEAUCOUP! !

  89. LINKS! > Protocol-Oriented Programming, WWDC 2015 developer.apple.com/videos/play/wwdc2015/408 > The ghost

    of Swift Bugs Future, Alexandros Salazar nomothetis.svbtle.com/the-ghost-of-swift-bugs- future
  90. PHOTO CREDITS! > Businessman, by Daniel X. O'Neil flickr.com/photos/juggernautco/6037175371 >

    Hammered Screw, by Justin Baeder flickr.com/photos/justinbaeder/5317820857 > Knot, by JP Davidson flickr.com/photos/jpdavidsonimages/4677642617