Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Brutal refactoring, lying code, the Churn, and other emotional stories from Legacy Land

495 views

Published on

Working effectively with legacy code isn’t all about creating test harnesses before refactoring algorithms. The “safety first” strategy doesn’t always apply. Not if the code you’re looking at is LYING IN YOUR FACE anyway.

In this talk I’ll show you what brutal refactoring is. I’ll show you the red glowy eyes of the Churn. And I’ll hold up some big warning signs that should prevent you from producing legacy code today.

Table flips allowed.

Published in: Software
  • Be the first to comment

Brutal refactoring, lying code, the Churn, and other emotional stories from Legacy Land

  1. 1. Brutal Refactoring Lying Code The Churn (and other emotional stories from) Legacy Land! Matthias Noback @matthiasnoback
  2. 2. ( °□°╯ )╯︵ ┻━┻
  3. 3. (Maintaining) legacy code is depressing
  4. 4. “Technical debt”
  5. 5. “Continuous improvement”
  6. 6. What can I know?
  7. 7. Besides outdated languages, old libraries, and frameworks you no longer understand...
  8. 8. Domain knowledge has left the building if ($product->isGrewBilly() && $customer->prefersPayTotum()) { $this->emailManager->sendTotumBillyAnnuitySummary(); }
  9. 9. Nobody knows why anymore
  10. 10. "Code should be self-documenting"
  11. 11. Please add comments
  12. 12. if (invoiceLinesHaveDifferentVatRates) { vatAmount = sumOfNetAmountsOnInvoiceLines * vatRate; } else { vatAmount = sumOfVatAmountsOnInvoiceLines; }
  13. 13. "Legacy code is code without an owner"
  14. 14. So... what should I do?
  15. 15. Read books
  16. 16. The Churn.
  17. 17. Core domain concepts
  18. 18. Guess: who are the monsters in your project?
  19. 19. Scaring away Churn monsters is a lot of work too!
  20. 20. Create invoice From time writing From contracts From sales order Create credit invoice Update sales order status Sales order stuff
  21. 21. Brutal refactoring
  22. 22. What else... should I do?
  23. 23. Little things?
  24. 24. Weed the ground
  25. 25. Pick up the stones, then put them back
  26. 26. Look your monster in the eyes
  27. 27. “Could this go somewhere else?”
  28. 28. What may I hope?
  29. 29. How did we get here?
  30. 30. Different developers Changing landscape Bad management Bad developers
  31. 31. You know what to do... ● Write tests from the start ● Document code and architecture decisions ● Agree on a coding style ● Enforce a coding standard ● Run static analysis tools And so on...
  32. 32. You can hope that people will do this from now on (actually, force them...)
  33. 33. The secret: most code could remain untouched
  34. 34. Consolidate
  35. 35. Not everything needs “consolidation”
  36. 36. Again … What may I hope?
  37. 37. Naive?
  38. 38. This is it
  39. 39. Do what you can do
  40. 40. “Burnout”
  41. 41. This is it

×