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

Le projet Legacy, quelles stratégies pour s'en sortir ? — Tech.rocks 2019

Le projet Legacy, quelles stratégies pour s'en sortir ? — Tech.rocks 2019

Arnaud LEMAIRE
PRO

December 04, 2019
Tweet

More Decks by Arnaud LEMAIRE

Other Decks in Programming

Transcript

  1. What is Legacy Code ?
    Definition

    View Slide

  2. A code
    you want to change
    that no one understands
    but still provides value.
    Definition

    View Slide

  3. A code without
    predictability
    Definition

    View Slide

  4. A code without
    predictability
    Definition
    Developers have no idea how long a
    change can take
    01.

    View Slide

  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

    View Slide

  6. 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

    View Slide

  7. A code with no test
    Definition

    View Slide

  8. 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

    View Slide

  9. Hello,
    I work in the finance industry
    at Lgo.group.
    My name is Arnaud LEMAIRE,
    And my twitter handle is
    @lilobase
    Who am I?

    View Slide

  10. This talk is focused on
    strategic considerations
    and not tactical ones
    Disclaimer

    View Slide

  11. A natural process
    Why does it appear?

    View Slide

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

    View Slide

  13. A natural process
    Why does it appear?
    Add lines of code
    More complexity

    View Slide

  14. A natural process
    Why does it appear?
    Add lines of code
    More complexity
    Increase in
    software entropy

    View Slide

  15. A natural process
    Why does it appear?
    Add lines of code
    More complexity
    Increase in
    software entropy
    Legacy
    Code

    View Slide

  16. You need to let your
    software die*
    A natural process that
    cannot be stopped

    View Slide

  17. You need to let your
    software die*
    * part of your software
    01.
    A natural process that
    cannot be stopped

    View Slide

  18. You need to let your
    software die*
    * part of your software
    01.
    02. Without bringing the remaining
    parts with it
    A natural process that
    cannot be stopped

    View Slide

  19. You need to let your
    software die*
    * part of your software
    01.
    02. Without bringing the remaining
    parts with it
    03. Optimize your software for
    replacement
    A natural process that
    cannot be stopped

    View Slide

  20. But that can be slowed
    down
    A natural process that
    cannot be stopped

    View Slide

  21. Strategies
    at the code level
    Legacy Code

    View Slide

  22. Would you rather go to the
    dentist twice a year or
    brush your teeth every day?
    When to refactor

    View Slide

  23. When to refactor
    Always leave the
    campground cleaner
    than you found it.

    View Slide

  24. Always leave the
    campground cleaner
    than you found it.
    When to refactor
    This is the « boy scout rule »
    01.

    View Slide

  25. Always leave the
    campground cleaner
    than you found it.
    When to refactor
    This is the « boy scout rule »
    01.
    Developing a new feature and
    refactoring doesn’t mix well!
    02.

    View Slide

  26. 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.

    View Slide

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

    View Slide

  28. Stop the weekly
    technical debt
    repayment session
    When to refactor
    The « We’ll fix it later » syndrome
    01.

    View Slide

  29. 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

    View Slide

  30. 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.

    View Slide

  31. Avoid the big bang refactoring

    View Slide

  32. The mikado™ method
    How to refactor

    View Slide

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

    View Slide

  34. The Hotspot™ method
    How to refactor

    View Slide

  35. The Hotspot™ method
    How to refactor

    View Slide

  36. The Hotspot™ method
    How to refactor

    View Slide

  37. The Hotspot™ method
    How to refactor

    View Slide

  38. Strategies
    at the system level
    Legacy system

    View Slide

  39. Refactoring ?
    How to tackle it?

    View Slide

  40. Refactoring ?
    How to tackle it?

    View Slide

  41. Refactoring ?
    How to tackle it?

    View Slide

  42. Rewrite ?
    How to tackle it?

    View Slide

  43. Rewrite ?
    How to tackle it?

    View Slide

  44. Ask your business to help you
    map your (business) domain
    01.
    Invoice
    Generation
    Invoicing
    Car rental

    View Slide

  45. Starting from your
    existing system
    Don’t start from your existing system

    View Slide

  46. Ask them to tag where there is
    room for improvement.
    02.
    Invoice
    Generation
    Invoicing
    Car rental

    View Slide

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

    View Slide

  48. Starting with your core
    business
    Don’t start by your core business
    Invoice
    Generation
    Invoicing
    Car rental

    View Slide

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

    View Slide

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

    View Slide

  51. Don’t do horizontal
    slicing !
    Don’t do horizontal slicing
    UI
    Persistence
    Service
    !

    View Slide

  52. Don’t do horizontal
    slicing !
    UI
    Persistence
    Service
    Don’t do horizontal slicing

    View Slide

  53. Rewrite it…
    04.
    Invoice
    Generation
    Invoicing
    New invoice
    Generation

    View Slide

  54. And put an anti-corruption layer
    to prevent legacy leakage
    05.
    Invoicing
    New invoice
    Generation
    Legacy API
    Legacy Database
    New Api
    ACL

    View Slide

  55. Invoicing
    New invoice
    Generation
    Legacy DB Event bus

    View Slide

  56. Invoicing
    New invoice
    Generation
    Legacy DB Event bus
    Hidden dependencies

    View Slide

  57. Invoicing
    New invoice
    Generation
    Legacy DB Event bus

    View Slide

  58. Replace the old legacy system
    06.
    Invoicing
    Invoice
    Generation
    New invoice
    Generation

    View Slide

  59. Replace the old legacy system
    06.
    Invoicing
    New invoice
    Generation

    View Slide

  60. Repeat
    07.
    Invoice
    Generation
    Invoicing
    Car rental

    View Slide

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

    View Slide

  62. The Ship of Theseus
    strategy also known as the
    Strangler pattern
    How to tackle it?

    View Slide

  63. The Ship of Theseus
    strategy also known as the
    Strangler pattern
    How to tackle it?
    You’ll need to coordinate your
    actions at the system level
    01.

    View Slide

  64. The Ship of Theseus
    strategy 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

    View Slide

  65. The Ship of Theseus
    strategy 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!

    View Slide

  66. • The Mikado method (Ellnestam & Brolund)

    • Software Design X-Rays (Thornhill)

    • Working Effectively with Legacy Code (Feather)

    • Refactoring (Fowler)
    Going further
    Thanks to
    Michael C. Feather, Adam Thornhill, Cyrille Martraire,
    Thomas Pierrain, Martin Fowler, Jean-Baptiste Dusseaut,
    Ola Ellnestam, Daniel Brolund, Adrian Bolboaca

    View Slide

  67. Thank you!
    I work in the finance industry
    at Lgo.group.
    My name is Arnaud LEMAIRE,
    And my twitter handle is
    @lilobase

    View Slide