refactoring toward deeper insight
play

Refactoring Toward Deeper Insight DDD Cologne Bonn Meetup / Jul 2, - PowerPoint PPT Presentation

Refactoring Toward Deeper Insight DDD Cologne Bonn Meetup / Jul 2, 2020 Christoph Baudson / @sustainablepace Christoph Baudson Software dev at REWE Digital since 08/2015 Organizer of the DDD Meetup Cologne @sustainablepace /


  1. Refactoring Toward Deeper Insight DDD Cologne Bonn Meetup / Jul 2, 2020 Christoph Baudson / @sustainablepace

  2. Christoph Baudson ● Software dev at REWE Digital since 08/2015 ● Organizer of the DDD Meetup Cologne ● @sustainablepace / sustainablepace.net

  3. 1. Some theory 2. Example a. The domain b. Let’s code!

  4. Domain Developers Domain experts Model

  5. Misconception! Modeling in Domain-Driven Design is a waterfall -like big design up-front , and therefore not agile

  6. Insights ● No one gets the model correct the first time. ● The model changes over time. ● The model is never done. ● The model needs to be refactored throughout the development lifecycle.

  7. Micro-Refactorings

  8. Refactoring to patterns Micro-Refactorings

  9. Refactoring to deeper insight Refactoring to patterns Micro-Refactorings

  10. Domain Developers Domain experts Model

  11. Misconception! When doing µServices , doing a rewrite is easy

  12. Insights ● The domain knowledge is lost after rewriting ● All dialogue has to happen all over again. ● It’s hard to guarantee it will work as before. ● Doing the same thing twice and expecting improvements is foolish. ● The domain model is an asset!

  13. 1. Some theory 2. Example a. The domain b. Let’s code!

  14. Deposit Categories

  15. Deposit Map Updates after 2 weeks

  16. 1. Some theory 2. Example a. The domain b. Let’s code!

  17. INFRASTRUCTURE APPLICATION SERVICES DOMAIN

  18. Refactoring to patterns Micro-Refactorings

  19. INFRASTRUCTURE APPLICATION SERVICES DOMAIN

  20. Creates the deposit map, based on the last update.

  21. Nullable?

  22. What does Nullable? min date mean?

  23. What does Nullable? min date mean? Another from date?

  24. What does Nullable? min date mean? Another from date? -> Nullable input is leaking in from infrastructure

  25. Why should a service assemble parts of the Map? I need to think about this...

  26. Why should a service assemble parts of the Map? I need to think about this... -> The deposit map should be build in the domain

  27. INFRASTRUCTURE APPLICATION SERVICES DOMAIN

  28. The boundaries are not enforced. ….and this obscures the business logic. Is there any?

  29. Is there anything to be learned from the model?

  30. YES! We forgot about another use case ;)

  31. -> Let’s add these concepts of the model to the code...

  32. -> Let’s add these concepts of the model to the code... Input is no longer nullable!

  33. INFRASTRUCTURE APPLICATION SERVICES DOMAIN

  34. -> Null check is moved outwards to infrastructure

  35. -> Null check is moved outwards to infrastructure There is a service for each use case now...

  36. Misconception! Don’t repeat yourself!

  37. INFRASTRUCTURE APPLICATION SERVICES DOMAIN

  38. -> Let’s move the deposit map creation to the domain

  39. Two different public factory methods

  40. dataDrop is encapsulated in model Naming could be improved...

  41. Data conversion happens in the background

  42. INFRASTRUCTURE APPLICATION SERVICES DOMAIN

  43. Apparently, there is no business logic...

  44. Apparently, there is no business logic... Added a new repository method to eliminate nullability...

  45. There is one business rule that was obscured before...

  46. There is one business rule that was obscured before... OK! We send a full map if the categories have been updated :)

  47. Parameters are not null. Min Date has been eliminated.

  48. Refactoring to deeper insight Refactoring to patterns Micro-Refactorings

  49. 1. Some theory 2. Example a. The domain b. Let’s code!

  50. Afterthoughts ● It might not be the best example ● We were merely reminded about domain concepts we didn’t translate to code ● It was not a breakthrough ● But the code is now aligned again with the domain model! Hexagon ftw!

  51. Recommendations

  52. Let’s learn more about tactical design. Contact me! Questions? Christoph Baudson / @sustainablepace

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend