Approval Tests, TCR, and Menders
On September 9, 2020, I co-organized the 3rd edition of The Legacy of SoCraTes with my partner in crime Adrian Bolboacă.
It’s a half-a-day remote conference where 5 speakers share their tips to deal with Legacy Code.
This edition had an accent on bringing existing code under tests. We talked about Approval Testing a lot. I have a dedicated page for that. These talks are a great opportunity to learn more and see it in action.
Without further ado, let me tell you how each talk can help you deal with your existing codebase.
Barney Dellar kick-started this conference by demonstrating the Approval Testing technique, on the Gilded Rose refactoring kata, in C++.
I like this talk because it shows the technique in action, on concrete code.
Also, Gilded Rose is an exercise I recommend doing if you want to get better at refactoring existing code.
Watch him get the code under test in no-time:
Approval Testing, again?!
Well, this was intentional. Emily Bache follow-up on Barney’s talk to go further with the techniques.
She has been using this technique in lots of situations for many years. It’s especially useful when working with legacy code. But there are common pitfalls to avoid and best practice to learn.
Oh and if you don’t know Emily, she’s the expert in coding exercises. Most of the refactoring katas I would recommend can be found in her GitHub, in many different languages: github.com/emilybache?tab=repositories&q=refactoring
Watch her talk to see how she compares unit tests and approval tests methodologies:
Did you noticed she uses a similar definition of Legacy code of mine:
Valuable code that works, developers find it difficult and we need to change it safely.
This time, these techniques are not from me 😁
In this talk, Jonathan presents 7 techniques that can be handy:
- Know your I/O frameworks
- Find a stronghold
- Analyze call stacks
- Start reading from the outputs
- Count words (I wrote about this one in details)
- Filter on control flow
- Scan for the main action
See them in action in his talk:
Test, Commit, or Revert (TCR) is a technique that was popularized by Kent Beck. You can think about it as a variant of TDD, pushing the programmer to do very small changes.
My friend Khaled Souf had the opportunity to actually use it on a Legacy rescue project. In this talk, he shares his experience and explains why it’s really efficient when you’re dealing with existing, untested code:
Finally, I had the pleasure to host M. Scott Ford to talk about developers’ mindsets.
We’re all familiar with “makers”. But it takes a different state of mind to really enjoy mending code.
Scott presents 4 different traits:
- The rapid prototyper
- The feature builder
- The emergency responder
- The software remodeler
He goes into the details of what are the strengths and weaknesses of each, and in which case each is best suited.
I personally don’t like putting people inside boxes. We made that clear with Scott as we discussed how each of us can be in many boxes at the same time, or switch depending on the context.
This is a really inspiring talk I recommend you to watch if you feel alone, fighting with your codebase:
If you want to connect with other menders (like me!), I recommend you join the Legacy Code Rocks community. There is a Slack group and a weekly virtual meetup.
If you join there, come and say hi to me 👋
There’s no fixed schedule, but I like to organize this short conference every few months. I reach out to a few speakers to build an interesting agenda, then we set up the event.
Everything is FREE. Attending is the opportunity to directly ask questions to these speakers, from the comfort of your home.
If that’s something you’d like to hear about, subscribe to my newsletter below 👇
I publish my weekly tips on Legacy Code here. I also tell my subscribers in advance about the conference and the agenda, so they don’t miss out. Join them!