Defensive Code Design @ Phpro weekend

Defensive Code Design @ Phpro weekend

In this presentation, I'll take you through a journey of "How to make changing a username complex …".
We'll discover some design patterns together whilst refactoring a legacy god controller into smaller well designed chunks.
Will the result actually be complexer? Come and find out!

In a second chapter, we'll handle some insane never-changing business requirements together. Spoiler alert: The requirements will change ...

Parental Advisory : The presentation will contain random memes and buzzwords like : hexagonal architecture, commandbus, functional programming, immutability, pure functions, ...

6c18f9874bd8dd408e41d77518987a0e?s=128

Toon Verwerft

October 11, 2019
Tweet

Transcript

  1. 1.
  2. 7.
  3. 8.
  4. 9.
  5. 10.
  6. 12.
  7. 14.
  8. 19.
  9. 21.
  10. 27.
  11. 28.
  12. 30.
  13. 31.
  14. 34.
  15. 39.
  16. 41.
  17. 42.
  18. 47.
  19. 50.
  20. 51.
  21. 55.
  22. 56.
  23. 58.
  24. 61.
  25. 64.
  26. 65.
  27. 66.
  28. 69.
  29. 71.
  30. 73.

    Question  :   Dude  …  you  are  very  optimistic  about

     the   connection How  can  we  log  stuff?
  31. 76.
  32. 77.
  33. 78.
  34. 79.
  35. 80.
  36. 82.
  37. 83.
  38. 85.

    Level Urgency Notification Debug / / Info / / Notice

    / / Warning / / Error 1d / Critical 2-­‐4h Push Alert 2h Push Emergency <1h Push
  39. 86.
  40. 88.
  41. 90.
  42. 91.
  43. 92.
  44. 93.
  45. 94.
  46. 95.

    Positive: • Every  function  does  1  thing • Every  class

     does  1  thing • Easy  to  test • Easy  to  debug • Easy  to  extend Negative: • We  made  a  simple  task   complex  (but  not  really) • It  takes  a  lot  of  boilerplate   code • You  have  to  know  what  you   are  doing!
  47. 97.
  48. 98.
  49. 99.
  50. 100.
  51. 102.

    Example  :   The  total  price  of  an  invoice is

     20  EUR  per  invoiced  items.
  52. 103.
  53. 105.
  54. 106.
  55. 108.
  56. 109.

    Next  feature  request:   Please  make  it  25  EUR  per

     invoice  line! Ah  yea:  only  the  even  lines  count
  57. 110.
  58. 111.
  59. 112.
  60. 113.
  61. 114.
  62. 115.
  63. 117.
  64. 118.
  65. 119.
  66. 120.
  67. 121.
  68. 122.
  69. 124.