Slide 1

Slide 1 text

Applied Domain Driven Design Applied Domain Driven Design on legacy code on legacy code Khaled Souf twitter: @khaledsouf 1

Slide 2

Slide 2 text

About Me About Me more details on : https://ksouf.com 2

Slide 3

Slide 3 text

What is a legacy code? 3

Slide 4

Slide 4 text

"A code without a test." -- Michael C. Feathers (Author of working effectively with legacy code) 4

Slide 5

Slide 5 text

5

Slide 6

Slide 6 text

We are talking about lost knowledge. We are talking about lost knowledge. How the code works (actually). How the code should work (how it is expected to work). 6

Slide 7

Slide 7 text

Somebody knows the history of all that code!!! 7

Slide 8

Slide 8 text

Event storming to the rescue Event storming to the rescue 8

Slide 9

Slide 9 text

Event storming: How it works? Event storming: How it works? Gather the right people in the same room (those who ask the questions and those who have the answer) Provide unlimited modeling space Explore the domain starting from Domain Events 9

Slide 10

Slide 10 text

Look up/out for these people (Anti-Patterns) Look up/out for these people (Anti-Patterns) Dungeon Master Existing System Expert 10

Slide 11

Slide 11 text

Who is the Dungeon Master? Who is the Dungeon Master? "The Dungeon Master is the author of the original software, that used to support the business in the early days... in facts he knows the software better than anyone else. Even if he’s not any more a software developer, he’s still at close distance from its creation." -- Alberto Brandolino (Inventor of Event Storming) 11

Slide 12

Slide 12 text

Dungeon Master Dungeon Master Do Mob/Pair programming with him with one Exceptional rule: the Dungeon Master should have less the keyboard than others. Try to do some scratch refactoring "Lean to the compiler" 12

Slide 13

Slide 13 text

Who is the Existing System Expert? Who is the Existing System Expert? Thinks that he master the Domain but actually he is an expert of the existing legacy system Can be a QA Engineer, a User and even the Product Owner 13

Slide 14

Slide 14 text

Existing System Expert Existing System Expert Ask them to run a global demo of the system How they test the application (maybe you can have an nice surprise as an end to end automated tests already implemented) 14

Slide 15

Slide 15 text

Try to get the history of the system. Try to get the history of the system. Identify deprecated features. Figure out the "hidden features" (if there is). Check if there is a shift of the core domain (usually there is). 15

Slide 16

Slide 16 text

Now we have enough confidence to take a decision. Now we have enough confidence to take a decision. Based on my experience, we have three choices based on our understanding of the legacy system. 16

Slide 17

Slide 17 text

Low level of confidence. Low level of confidence. We expose our legacy system/code as a service (as an api for example). Use the Open Host Service (OHS) pattern to publish legacy features on a simpler way that it is. Create bubble context as new feature is needed. 17

Slide 18

Slide 18 text

Low level of confidence. Low level of confidence. 18

Slide 19

Slide 19 text

Medium Level of confidence. Medium Level of confidence. Create bubble context as new feature is needed. Every bubble context has its own way to ask information from legacy using Anti Corruption Layer (ACL) pattern on the use case service level. 19

Slide 20

Slide 20 text

Medium Levelof confidence. Medium Levelof confidence. 20

Slide 21

Slide 21 text

High Level of confidence. High Level of confidence. Create bubble context as new feature is asked or bug fixed is asked. If it is a bug fix refactor and extract the feature on new bubble context. Every bubble context has is own way to ask information from legacy using ACL's calling low level services. 21

Slide 22

Slide 22 text

High Level of confidence. High Level of confidence. 22

Slide 23

Slide 23 text

Warp-up Warp-up take an action only if there is an opportunity. Try to understand how the Legacy system works using event storming and Mob/Pair programing. Work wisely with the Dungeon Master and the Existing System Expert(They can be harmful to the legacy system). Sometimes your level of confidence can be different in every slice of the system: combine all the patterns used before (Legacy as Service, OHS, ACL, ...) 23

Slide 24

Slide 24 text

Thank you for attending Thank you for attending Questions ? website: https://ksouf.com 24