$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
  2. @kenny_baas

  3. @kenny_baas

  4. @kenny_baas

  5. @kenny_baas

  6. @kenny_baas

  7. @kenny_baas

  8. @kenny_baas

  9. @kenny_baas

  10. @kenny_baas

  11. @kenny_baas

  12. @kenny_baas No I won’t rant a lot about “The next

    internet explorer type microsoft legacy for generations to come”
  13. Legacy Software – Kenny Baas-Schwegler @kenny_baas Photo by Gabriella Clare

    Marino on Unsplash I <3
  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/
  15. @kenny_baas Photo by Evan Qu on Unsplash Design heuristic “Favour

    monolithic architecture over microservices architecture”
  16. @kenny_baas

  17. @kenny_baas Photo by Christopher Burns on Unsplash But…But I thought

    we should get rid of Legacy software, not create more?
  18. @kenny_baas Photo by Manish Tulaskar on Unsplash Monolithic architecture !=

    BAD Monolithic architecture != Legacy
  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
  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.
  21. @kenny_baas

  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
  23. @kenny_baas https://www.huffingtonpost.co.uk/entry/american-tweets-about-great-british-bake-off_uk_61733eaee4b03072d6f6d012

  24. @kenny_baas

  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
  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
  27. @kenny_baas Instead of one canonical language, create multiple bounded languages

  28. @kenny_baas Business Architects Developers

  29. @kenny_baas

  30. @kenny_baas

  31. @kenny_baas

  32. @kenny_baas A straight line between 2 points corresponds to a

    compass direction in reality..
  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
  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
  35. @kenny_baas Business Architects Developers

  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)
  37. @kenny_baas

  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
  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.
  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
  41. @kenny_baas Big Ball of Mud Software system that lacks a

    perceivable architecture and the model is implicit.
  42. @kenny_baas Photo by Fusion Medical Animation on Unsplash Then came

    Covid-19
  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
  44. @kenny_baas Photo by Evan Qu on Unsplash Guiding heuristic Discover

    and identify bounded context with EventStorming
  45. @kenny_baas

  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.
  47. @kenny_baas

  48. @kenny_baas Photo by Evan Qu on Unsplash Guiding heuristic Pick

    some boundaries to start with and iterate.
  49. @kenny_baas

  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/
  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
  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
  53. @kenny_baas

  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
  55. @kenny_baas

  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<AuditoriumSeating > GetAuditoriumSeating (ShowId showId); }
  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<AuditoriumSeating > 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<string, Row>(); foreach (var (rowName, seatDtos) in auditoriumDto.Rows) { ………………
  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.
  59. @kenny_baas

  60. @kenny_baas Photo by Evan Qu on Unsplash Design heuristic (repeated)

    “Favour monolithic architecture over microservices architecture”
  61. @kenny_baas

  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”
  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
  64. @kenny_baas

  65. @kenny_baas

  66. @kenny_baas

  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”
  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
  69. @kenny_baas

  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”
  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
  72. @kenny_baas

  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)”
  74. @kenny_baas Follow Jabe Bloom: https://twitter.com/cyetain Follow Ben at HiredThought: https://twitter.com/HiredThought

  75. @kenny_baas

  76. @kenny_baas Photo by Evan Qu on Unsplash Guiding heuristic “You

    can use Monolith and Microservices architecture together!!”
  77. @kenny_baas https://github.com/ddd-crew/ddd-starter-modelling-process

  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
  79. @kenny_baas

  80. @kenny_baas Photo by Evan Qu on Unsplash Design heuristic “Implement

    requirements and information based on the responsibility of your bounded context”
  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
  82. @kenny_baas

  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

  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
  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”
  86. @kenny_baas #CatTax @kenny_baas Baasie.com xebia.com/blog/author/kbaas/ https://speakerdeck.com/baasie https://virtualddd.com/