$30 off During Our Annual Pro Sale. View Details »

Domain-Driven Design heuristics for dealing with legacy software @ Techorama 2022

Domain-Driven Design heuristics for dealing with legacy software @ Techorama 2022

How can we get better as software designers? By becoming more aware of our design heuristics and being intentional as we cultivate and refine them. Heuristics aid in the design and even determine our attitude and behaviour. We each have our own (often implicit) heuristics acquired through reading, practice, and experience, especially when surrounded by legacy software. Let us share these heuristics during a modelling session! In this session, I'll present you with a legacy modelling problem, which I will show you how we can solve with DDD legacy patterns. I will explain the four strategies for getting started with DDD when you have a big commitment to legacy systems by Eric Evans. To really understand the strategy, I will explain the bounded context pattern and show you how you can implement the strategy in your architecture. Finally, I will share some personal heuristics when dealing with legacy software. You will leave this session with shared knowledge from experience in dealing with legacy software and how you can start Context mapping for strategic Domain-Driven Design patterns while surrounded by legacy!

Kenny Baas-Schwegler

October 11, 2022
Tweet

More Decks by Kenny Baas-Schwegler

Other Decks in Programming

Transcript

  1. Domain-Driven Design heuristics
    for dealing with legacy software
    Kenny Baas-Schwegler
    @kenny_baas
    Photo by Mathew Schwartz on Unsplash

    View Slide

  2. @kenny_baas

    View Slide

  3. @kenny_baas

    View Slide

  4. @kenny_baas

    View Slide

  5. @kenny_baas

    View Slide

  6. @kenny_baas

    View Slide

  7. @kenny_baas

    View Slide

  8. @kenny_baas

    View Slide

  9. @kenny_baas

    View Slide

  10. @kenny_baas

    View Slide

  11. @kenny_baas

    View Slide

  12. @kenny_baas
    No I won’t rant a lot about
    “The next internet explorer type microsoft legacy for generations to come”

    View Slide

  13. Legacy Software
    – Kenny Baas-Schwegler
    @kenny_baas
    Photo by Gabriella Clare Marino on Unsplash
    I <3

    View Slide

  14. @kenny_baas
    “anything that provides a plausible aid or direction in the
    solution of a problem but is in the final analysis unjustified,
    incapable of justification, and potentially fallible.
    – Billy Vaughn Koen - Nuclear Engineer
    Heuristic
    https://wirfs-brock.com/blog/2019/03/20/growing-your-personal-design-heuristics/

    View Slide

  15. @kenny_baas
    Photo by Evan Qu on Unsplash
    Design heuristic
    “Favour monolithic architecture over microservices architecture”

    View Slide

  16. @kenny_baas

    View Slide

  17. @kenny_baas
    Photo by Christopher Burns on Unsplash
    But…But I thought we should get rid of
    Legacy software, not create more?

    View Slide

  18. @kenny_baas
    Photo by Manish Tulaskar on Unsplash
    Monolithic architecture != BAD
    Monolithic architecture != Legacy

    View Slide

  19. @kenny_baas
    Legacy software
    In computing, a legacy system is an old method, technology,
    computer system, or application program/code, "of, relating
    to, or being a previous or outdated computer system," yet still
    in use.
    https://en.wikipedia.org/wiki/Legacy_system

    View Slide

  20. @kenny_baas
    Monolithic architecture
    A single-tiered software
    application in which different
    components combined into a
    single program form a single
    deployable unit. It can be a MVC
    approach or an API with a
    database.

    View Slide

  21. @kenny_baas

    View Slide

  22. @kenny_baas
    To communicate effectively, the code must be based on the
    same language used to write the requirements
    - the same language that the developers speak
    with each other and with domain experts
    - Eric Evans

    View Slide

  23. @kenny_baas
    https://www.huffingtonpost.co.uk/entry/american-tweets-about-great-british-bake-off_uk_61733eaee4b03072d6f6d012

    View Slide

  24. @kenny_baas

    View Slide

  25. @kenny_baas
    We all know or should know that language is fluid, liquid, subject to the
    whims of the people. Language evolves, as it should. Because language
    changes to accommodate new users, the older users resist and complain.
    http://tednellen.blogspot.com/2013/04/language-is-fluid.html

    View Slide

  26. @kenny_baas
    It is not the domain experts knowledge
    that goes to production, it is the
    assumption of the developers
    that goes to production
    - Alberto Brandolini

    View Slide

  27. @kenny_baas
    Instead of one canonical language,
    create multiple bounded languages

    View Slide

  28. @kenny_baas
    Business
    Architects
    Developers

    View Slide

  29. @kenny_baas

    View Slide

  30. @kenny_baas

    View Slide

  31. @kenny_baas

    View Slide

  32. @kenny_baas
    A straight line between 2 points
    corresponds to a compass direction in
    reality..

    View Slide

  33. @kenny_baas
    A straight line between 2 points corresponds to
    a compass direction in reality..
    • Except for points located in Greenland
    • Except for points located in Africa

    View Slide

  34. @kenny_baas
    A model is a simplified representation of a thing
    or phenomenon that intentionally emphasizes
    certain aspects while ignoring others.
    Abstraction with a specific use in mind.
    — Rebecca Wirfs-Brock

    View Slide

  35. @kenny_baas
    Business
    Architects
    Developers

    View Slide

  36. @kenny_baas
    Photo by Evan Qu on Unsplash
    Guiding heuristic
    Start communicating business change in
    contextual boundaries that form the bounded context
    (purpose, need, responsibility)

    View Slide

  37. @kenny_baas

    View Slide

  38. @kenny_baas
    Photo by Evan Qu on Unsplash
    Design heuristic
    When designing new bounded contexts, they should have one team who is
    owning that bounded context. A team can have multiple bounded context

    View Slide

  39. @kenny_baas
    Photo by Gloria Cretu on Unsplash
    Recap
    ● A legacy system is an old application program/code still in use.
    ● Monolith is a deployment strategy.
    ● Legacy != Monolith, and most legacy software is build as monoliths
    ● Most monoliths components are not designed in a DDD way, creating a
    disconnect with the business strategy and creating a big ball of mud.

    View Slide

  40. @kenny_baas
    Photo by Felix Mooneeram on Unsplash
    BigScreen
    ● Fictitious company
    ● International cinema chain with 80 cinema’s located in 12 different countries
    ● Custom software system
    ● The current system is completely entangled, a big ball of mud (BBoM) that has
    been around for many years

    View Slide

  41. @kenny_baas
    Big Ball of Mud
    Software system that lacks a
    perceivable architecture and the
    model is implicit.

    View Slide

  42. @kenny_baas
    Photo by Fusion Medical Animation on Unsplash
    Then came Covid-19

    View Slide

  43. @kenny_baas
    Requirements
    ● Reopen in approx 2-3 months
    ● 1.5 meters apart from reservations
    ● Sign a health check
    ● Able to go back when needed

    View Slide

  44. @kenny_baas
    Photo by Evan Qu on Unsplash
    Guiding heuristic
    Discover and identify bounded context with EventStorming

    View Slide

  45. @kenny_baas

    View Slide

  46. @kenny_baas
    Photo by Evan Qu on Unsplash
    Design heuristics
    ● Split according to the language.
    ● Split according to the departments.
    ● Split according to the users.

    View Slide

  47. @kenny_baas

    View Slide

  48. @kenny_baas
    Photo by Evan Qu on Unsplash
    Guiding heuristic
    Pick some boundaries to start with and iterate.

    View Slide

  49. @kenny_baas

    View Slide

  50. @kenny_baas
    Using collaborative modelling to build a
    shared understanding of your domain and use it to
    guide your design _is_ the philosophy behind DDD
    though. The rest is principles, patterns, and practices.
    — Mathias Verraes
    https://verraes.net/2021/09/what-is-domain-driven-design-ddd/

    View Slide

  51. @kenny_baas
    Requirements
    ● Reopen in approx 2-3 months
    ● 1.5 meters apart from reservations
    ● Sign a health check
    ● Able to go back when needed

    View Slide

  52. @kenny_baas
    3 Strategies + Evolution
    1. Bubble context
    2. Autonomous bubble
    3. Exposing Legacy as a service (LaaS)
    ➔ Expanding a bubble
    https://www.domainlanguage.com/wp-content/uploads/2016/04/GettingStartedWithDDDWhenSurroundedByLegacySystemsV1.pdf

    View Slide

  53. @kenny_baas

    View Slide

  54. @kenny_baas
    Anti-corruption Layer (ACL)
    Translation layers can be simple, even elegant, when bridging
    well-designed bounded contexts with cooperative teams. But when
    control or communication is not adequate to pull off a shared kernel,
    partner or customer/supplier relationship, translation becomes more
    complex. The translation layer takes on a more defensive tone.
    Therefore:
    As a downstream client, create an isolating layer to provide your system
    with functionality of the upstream system in terms of your own domain
    model. This layer talks to the other system through its existing interface,
    requiring little or no modification to the other system. Internally, the layer
    translates in one or both directions as necessary between the two models.
    ACL is more than a Translation Layer!
    From: https://www.domainlanguage.com/ddd/reference/
    https://virtualddd.com/sessions/20

    View Slide

  55. @kenny_baas

    View Slide

  56. @kenny_baas
    Repositories
    For each type of aggregate that needs global
    access, create a service that can provide the
    illusion of an in-memory collection of all
    objects of that aggregate’s root type.
    Set up access through a well-known global
    interface. Provide methods to add and remove
    objects, which will encapsulate the actual
    insertion or removal of data in the data store.
    public interface AuditoriumSeatings
    {
    Task GetAuditoriumSeating (ShowId
    showId);
    }

    View Slide

  57. @kenny_baas
    public class AuditoriumSeatingAdapter : AuditoriumSeatings
    {
    private readonly IProvideAuditoriumLayouts _auditoriumSeatingRepository
    ;
    private readonly IProvideCurrentReservations _reservationsProvider
    ;
    public AuditoriumSeatingAdapter
    (IProvideAuditoriumLayouts auditoriumSeatingRepository
    ,
    IProvideCurrentReservations reservationsProvider
    )
    {
    _auditoriumSeatingRepository = auditoriumSeatingRepository
    ;
    _reservationsProvider = reservationsProvider
    ;
    }
    public async Task> GetAuditoriumSeating
    (ShowId showId)
    {
    var auditoriumDto = await _auditoriumSeatingRepository
    .GetAuditoriumSeatingFor
    (showId.Id);
    var reservedSeatsDto = await _reservationsProvider
    .GetReservedSeats
    (showId.Id);
    return AdaptAuditoriumSeatingDto(auditoriumDto, reservedSeatsDto
    );
    }
    private static AuditoriumSeating AdaptAuditoriumSeatingDto(AuditoriumDto auditoriumDto,
    ReservedSeatsDto reservedSeatsDto
    )
    {
    var rows = new Dictionary();
    foreach (var (rowName, seatDtos) in auditoriumDto.Rows)
    { ………………

    View Slide

  58. @kenny_baas
    Ports and Adapters
    The hexagonal architecture, or
    ports and adapters architecture, is
    an architectural pattern used in
    software design. It aims at creating
    loosely coupled application
    components that can be easily
    connected to their software
    environment by means of ports
    and adapters. This makes
    components exchangeable at any
    level and facilitates test
    automation.

    View Slide

  59. @kenny_baas

    View Slide

  60. @kenny_baas
    Photo by Evan Qu on Unsplash
    Design heuristic
    (repeated)
    “Favour monolithic architecture over microservices architecture”

    View Slide

  61. @kenny_baas

    View Slide

  62. @kenny_baas
    Photo by Evan Qu on Unsplash
    Design heuristics
    (Competing)
    1. “Integrate through an API on application layer”
    2. “Integrate through an API on the database layer”

    View Slide

  63. @kenny_baas
    3 Strategies + Evolution
    1. Bubble context
    2. Autonomous bubble
    3. Exposing Legacy as a service (LaaS)
    ➔ Expanding a bubble
    https://www.domainlanguage.com/wp-content/uploads/2016/04/GettingStartedWithDDDWhenSurroundedByLegacySystemsV1.pdf

    View Slide

  64. @kenny_baas

    View Slide

  65. @kenny_baas

    View Slide

  66. @kenny_baas

    View Slide

  67. @kenny_baas
    Photo by Evan Qu on Unsplash
    Guiding heuristic
    “Either remove a bubble context, or dedicate resources and people to move
    towards an autonomous bubble context”

    View Slide

  68. @kenny_baas
    Photo by Yong Chuan Tan on Unsplash
    Black hole anti-pattern
    When a POC is put to production and not getting the time and
    people to decouple, making the bubble burst
    and be absorbed back by the Big Ball of Mud

    View Slide

  69. @kenny_baas

    View Slide

  70. @kenny_baas
    Photo by Evan Qu on Unsplash
    Value heuristic
    “Use Test-Driven Development and good unit testing practices
    to get fast feedback, and become more confident on changes”

    View Slide

  71. @kenny_baas
    3 Strategies + Evolution
    1. Bubble context
    2. Autonomous bubble
    3. Exposing Legacy as a service (LaaS)
    ➔ Expanding a bubble
    https://www.domainlanguage.com/wp-content/uploads/2016/04/GettingStartedWithDDDWhenSurroundedByLegacySystemsV1.pdf

    View Slide

  72. @kenny_baas

    View Slide

  73. @kenny_baas
    Photo by Evan Qu on Unsplash
    Guiding heuristic
    “Don’t rebuild functionality that works as intended
    and has no or little expected changes coming up.
    (Including software characteristics)”

    View Slide

  74. @kenny_baas
    Follow Jabe Bloom: https://twitter.com/cyetain
    Follow Ben at HiredThought: https://twitter.com/HiredThought

    View Slide

  75. @kenny_baas

    View Slide

  76. @kenny_baas
    Photo by Evan Qu on Unsplash
    Guiding heuristic
    “You can use Monolith and Microservices architecture together!!”

    View Slide

  77. @kenny_baas
    https://github.com/ddd-crew/ddd-starter-modelling-process

    View Slide

  78. @kenny_baas
    3 Strategies + Evolution
    1. Bubble context
    2. Autonomous bubble
    3. Exposing Legacy as a service (LaaS)
    ➔ Expanding a bubble
    https://www.domainlanguage.com/wp-content/uploads/2016/04/GettingStartedWithDDDWhenSurroundedByLegacySystemsV1.pdf

    View Slide

  79. @kenny_baas

    View Slide

  80. @kenny_baas
    Photo by Evan Qu on Unsplash
    Design heuristic
    “Implement requirements and information
    based on the responsibility of your bounded context”

    View Slide

  81. @kenny_baas
    3 Strategies + Evolution
    1. Bubble context
    2. Autonomous bubble
    3. Exposing Legacy as a service (LaaS)
    ➔ Expanding a bubble
    https://www.domainlanguage.com/wp-content/uploads/2016/04/GettingStartedWithDDDWhenSurroundedByLegacySystemsV1.pdf

    View Slide

  82. @kenny_baas

    View Slide

  83. @kenny_baas
    Reference from Trond Hjorteland: Sociotechnical System
    https://www.researchgate.net/publication/306242078_Assessing_the_impact_of_new_technology_on_complex_sociotechnical_systems

    View Slide

  84. @kenny_baas
    Photo by David Ramírez on Unsplash
    “Every tradeoff we make, that we might see as technical
    has also user and biz effects and are hence a sociotechnical tradeoff”
    – Ruth Malan / @ruthmalan

    View Slide

  85. @kenny_baas
    Photo by Gabriella Clare Marino on Unsplash
    “Our problems are not legacy software systems,
    these can be easily changed giving enough time and people.
    Our problem is we are dealing with legacy sociotechnical system,
    who have legacy best practices competing with emerging practices”

    View Slide

  86. @kenny_baas
    #CatTax
    @kenny_baas
    Baasie.com
    xebia.com/blog/author/kbaas/
    https://speakerdeck.com/baasie
    https://virtualddd.com/

    View Slide