Le projet Legacy : quelles stratégies pour s'en sortir ? — ATBDX 2020

Le projet Legacy : quelles stratégies pour s'en sortir ? — ATBDX 2020

Beb422437c1dfb5366f197919e41ac50?s=128

Arnaud LEMAIRE

October 28, 2020
Tweet

Transcript

  1. None
  2. What is Legacy Code ? Definition

  3. A code you want to change that no one understands

    but still provides value. Definition
  4. A code without predictability Definition

  5. A code without predictability Definition Developers have no idea how

    long a change can take 01. 02. There is no correlation between the business and the technical complexity 03. You don’t know when something will break
  6. A code with no test Definition

  7. A code with no test Definition « Most of the

    fear involved in making changes to large code bases is fear of introducing subtle bugs; fear of changing things inadvertently. Without test, you just don’t know whether things are getting better or worse. » — Michael Feathers
  8. An inverse problem Definition

  9. An inverse problem Definition Observations Causes Forward problem Inverse problem

  10. An inverse problem Definition

  11. Hello, I am a software developer. My name is Arnaud

    LEMAIRE, and you can find me on lilobase.me & @lilobase Who am I?
  12. This talk is focused on strategic considerations and not tactical

    ones Disclaimer
  13. A natural process Why does it appear?

  14. A natural process Why does it appear? Add lines of

    code More complexity Increase in software entropy Legacy Code
  15. You need to let your software die* A natural process

    that cannot be stopped
  16. You need to let your software die* * part of

    your software 01. 02. Without bringing the remaining parts with it 03. Write code that is easy to delete, not easy to extends A natural process that cannot be stopped
  17. But that can be slowed down A natural process that

    cannot be stopped
  18. That can be speeded up or slowed down Why does

    it appear? Refactoring helps to keep complexity under control 01. 02. A good software design is critical in the long term 03. Technical debt ≠ legacy software, but it can accelerate the process
  19. What do we do now ?

  20. You need to have empathy, and take the time to

    understand the project's history What do we do now ?
  21. Strategies at the code level Legacy Code

  22. Would you rather go to the dentist twice a year

    or brush your teeth every day? When to refactor
  23. When to refactor Always leave the campground cleaner than you

    found it.
  24. Always leave the campground cleaner than you found it. When

    to refactor This is the « boy scout rule » 01. 03. When you found a bug, first write a test that triggers it, then fix it. Developing a new feature and refactoring doesn’t mix well! 02. 04. Beware of the broken windows syndrome
  25. Culture emerge from practices, not the other way around. When

    to refactor
  26. Stop the weekly technical debt repayment session When to refactor

  27. Stop the weekly technical debt repayment session When to refactor

    The « We’ll fix it later » syndrome 01. 02. The same cause always produces the same effect Instead provide a learning time, so you stop writing legacy code 03.
  28. The big bang refactoring

  29. The mikado™ method How to refactor

  30. The mikado™ method How to refactor Undo when an experiment

    fail
  31. The golden master Testing How to refactor

  32. The golden master Testing « In nearly every legacy system,

    what the system does is more important that what it’s supposed to do. » — Michael Feathers How to refactor
  33. The Hotspot™ method How to refactor

  34. The Hotspot™ method How to refactor

  35. The Hotspot™ method How to refactor

  36. The Hotspot™ method How to refactor

  37. Strategies at the system level Legacy system

  38. Refactoring ? How to tackle it?

  39. Refactoring ? How to tackle it?

  40. Rewrite ? How to tackle it?

  41. Rewrite ? How to tackle it?

  42. The Ship of Theseus strategy How to tackle it?

  43. The Ship of Theseus strategy How to tackle it?

  44. Ask your business to help you map your (business) domain

    01. Invoice Generation Invoicing Car rental
  45. Starting from your existing system Don’t start from your existing

    system
  46. Ask them to tag where there is room for improvement.

    02. Invoice Generation Invoicing Car rental
  47. Select a tagged support service with few dependencies 03. Invoice

    Generation Invoicing
  48. Starting with your core business Don’t start with your core

    business Invoice Generation Invoicing Car rental !
  49. Starting with your core business Don’t start with your core

    business Too many legacy dependencies 01. 02. The developers will need some training…
  50. Don’t do horizontal slicing ! Don’t do horizontal slicing UI

    Persistence Business !
  51. Don’t do horizontal slicing ! UI Persistence Business Do vertical

    slicing
  52. Rewrite it… 04. Invoice Generation Invoicing New invoice Generation

  53. And put an anti-corruption layer to prevent legacy leakage 05.

    Invoicing New invoice Generation Legacy API Legacy Database New Api ACL
  54. The Anti-Corruption Layer Anti-Corrupution Layer The Greenfield code must not

    call directly the Legacy code 01. 02. The Legacy code must not call directly the Greenfield code 03. Even through the persistence system: database or event/message bus
  55. Invoicing New invoice Generation Legacy DB Event bus Hidden dependencies

  56. Invoicing New invoice Generation Legacy DB Event bus

  57. Our system Vendor API ACL An anti-corruption layer can also

    protect us from the outside world
  58. Invoice Generation Invoicing New invoice Generation Replace the old legacy

    system 06.
  59. Invoice Generation Invoicing New invoice Generation Diff system Error Log

  60. Repeat 07. Invoice Generation Invoicing Car rental

  61. Until you can reach the core 08. Invoice Generation Invoicing

    Car rental
  62. This strategy is also known as the Strangler pattern How

    to tackle it?
  63. This strategy is also known as the strangler pattern How

    to tackle it? You’ll need to coordinate your actions at the system level 01. 02. Beware of functional debt 03. Optimise your new system for replacement!
  64. • The Mikado method (Ola Ellnestam; Daniel Brolund) • Software

    Design X-Rays (Adam Thornhill) • Working Effectively with Legacy Code (Michael C. Feather) • Refactoring (Martin Fowler) • Accelerate (Jez Humble; Nicole Forsgren; Gene Kim) Going further Thanks to Cyrille Martraire, Thomas Pierrain, Jean-Baptiste Dusseaut, Adrian Bolboaca
  65. Hello, I am a software developer. My name is Arnaud

    LEMAIRE, and you can find me on lilobase.me & @lilobase Thanks
  66. https://roti.express/r/atbdx20 Feedback ?