Skip to content
Home » DDD, Refactoring and Legacy Code

DDD, Refactoring and Legacy Code

Last night I attended the DDD NL meetup where the challenge was to refactor some OO code, one file at a time without breaking (or changing) any tests as we went

A brilliant challenge and one that I was most definitely not up to. In my defence, I choose to do this in Kotlin (a language I’ve barely used) using IntelliJ (an editor I’ve also very little familiarity with). Java was the other choice for the exercise but I’ve never been a fan!

Luckily, I wasn’t getting paid for the output I produced.

What became quickly clear to me in this exercise is that language knowledge and skills trump all. Knowing the tricks in Java and Kotlin helps rewrite classes. Overloading methods or constructors meant that like-for-like substitutions could occur in single files and tests still pass.

So we exercised the Test->Code->Refactor loop a few times, getting better as we did it. In this case, though, the tests were already written, we were making small jumps in Code space only. And what we noticed is that some Refactoring was also occurring.

A self-selected group of senior software engineers, working in pairs, finding good solutions that would fit the brief over a couple of hours. And then a nice discussion about C4 and Wardley Mapping to finish with.

No matter what your experience level and knowledge, it’s always good to get into your community and find out what’s going on.

Also reminded me that I need to finish reading the Michael Feathers book “Working Effectively with Legacy Code”.