Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Experimental Refactoring with Go

Experimental Refactoring with Go

Refactoring is essential to the software lifecycle. Can we make it safe enough to be a part of every company's CD workflow? In this talk attendees will learn how to: utilise multi-step deploys; tame feature flags; run multiple code paths concurrently in production without influencing users.

3f4444967dfc7a5a2a71d24175d94c3c?s=128

Jelmer Snoeck

August 03, 2018
Tweet

Transcript

  1. Experimental Refactoring

  2. FIND ME github.com/jelmersnoeck twitter.com/jelmersnoeck Jelmer Snoeck ABOUT ME - Tech

    Lead at manifold.co - Kubernetes - Terraform - Gopher since 2013 - Kubelist Contributor
  3. $ tree - What and why? - Techniques & Tools

    - Zero Downtime Refactoring - Experimental Refactoring
  4. Photo by Dan Gold on Unsplash Refactoring

  5. Code refactoring is the process of restructuring existing computer code

    without changing its external behavior. Wikipedia
  6. Refactoring is a controlled technique for improving the design of

    an existing code base. Martin Fowler
  7. Refactoring is changing things, deploying it and hoping it didn’t

    break anything else. Most Developers
  8. Photo by Emily Morter on Unsplash Why

  9. Photo by Alfons Morales on Unsplash Readability

  10. Photo by Anton Darius on Unsplash Code smells

  11. Code smells - Duplication - Feature envy - Large methods

    - Dead code - …
  12. Photo by Glen Carrie on Unsplash Bugs

  13. Product Changes Photo by Chris Lawton on Unsplash Product changes

  14. Product changes - New features - Modify existing features -

  15. Photo by Nainoa Shizuru on Unsplash Performance + scalability

  16. Performance - Change of underlying package - Change of underlying

    algorithm - …
  17. Scalability - Userbase growth (100 users to 100m users) -

    Team growth (10 developers to 500 developers) - …
  18. Photo by Anoir Chafik on Unsplash

  19. Techniques Photo by Uriel Soberanes on Unsplash

  20. Techniques - Interface Abstraction - Type Aliasing (Go 1.9+) -

    Nil Objects - …
  21. Interfaces (Abstraction) Photo by Rene Böhmer on Unsplash

  22. None
  23. None
  24. None
  25. None
  26. None
  27. Photo by Kipras Štreimikis on Unsplash Type Aliasing

  28. None
  29. None
  30. None
  31. None
  32. None
  33. Photo by Aaron Burden on Unsplash Nil Objects

  34. None
  35. None
  36. None
  37. None
  38. None
  39. None
  40. None
  41. Photo by Philip Swinburn on Unsplash Tools

  42. Detection Tools - CodeCov - Linting - …

  43. CodeCov Photo by Samuel Zeller on Unsplash

  44. None
  45. None
  46. None
  47. None
  48. None
  49. Linting Photo by Terri Bleeker on Unsplash

  50. None
  51. None
  52. None
  53. Refactoring Tools - Tests - Security that it still works

    - Gotests - Benchmarks - go test -bench=. - IDE - Extract methods - Find duplication easily
  54. gotests Photo by rawpixel on Unsplash

  55. None
  56. None
  57. None
  58. None
  59. go test -bench=. Photo by Ashley Baxter on Unsplash

  60. None
  61. None
  62. None
  63. None
  64. Photo by Mark Hessling on Unsplash

  65. Photo by Jyotirmoy Gupta on Unsplash

  66. Photo by Marcus Benedix on Unsplash

  67. Zero Downtime Refactoring Photo by Masaaki Komori on Unsplash

  68. Multi Step Changes Photo by Jake Hills on Unsplash

  69. None
  70. None
  71. None
  72. None
  73. None
  74. None
  75. None
  76. Photo by Jane Carmona on Unsplash Feature Flags

  77. None
  78. Why use Feature Toggles? - Early Access to Features -

    Incremental roll outs to test hypothesis - Calendar Events (Mother’s day, Launches, …) - …
  79. None
  80. None
  81. None
  82. Metrics Photo by Carlos Muza on Unsplash

  83. None
  84. Experimental Refactoring Photo by chuttersnap on Unsplash

  85. None
  86. None
  87. Photo by chuttersnap on Unsplash

  88. None
  89. None
  90. None
  91. None
  92. None
  93. None
  94. None
  95. None
  96. None
  97. None
  98. None
  99. None
  100. None
  101. None
  102. @jelmersnoeck manifold.co Thanks!

  103. Reading list - https://speakerdeck.com/campoy/understanding-nil - https://talks.golang.org/2016/refactor.article - https://dave.cheney.net/2013/06/30/how-to-write-benchmarks-in-go - https://github.com/cweill/gotests

    - https://github.com/github/scientist - https://github.com/jelmersnoeck/experiment - http://featureflags.io/ - https://github.com/launchdarkly/go-client - https://github.com/checkr/flagr