I'm wondering how my way of working through legacy code may be different from someone more seasoned…
Ooooh I feel you. That is a very, very common thought to have my friend 😃
In fact, most developers are only exposed to Legacy Code at work. You have to maintain an existing codebase because that's what is bringing money to the company. After all, Legacy Code is valuable code you're afraid to change.
If you are lucky enough, you'll be working with seasoned developers who can teach you their tricks. But this is not very common.
So how do you know if you're doing it right? What can you do to make it easier to deal with Legacy Code?
Let me rephrase that: what can you do to make it easier to perform working on Legacy Code?
Have you ever felt impressed by how acrobats make their moves look so easy, but you know it's damn hard?
The thing is: performers spend most of their time practicing.
We, developers, spend most of our time performing. Little time is dedicated to actual practice. You know, trying some new moves, repeating them, perfecting them. Exercising our skills. Making it so when we are on the battlefield, we instinctively know what could work.
Practicing is key in making Legacy Code easier to deal with.
Let's briefly cover the few questions that are popping in your head:
- Where to practice? On coding exercises that are designed for this. Here's the list of 5 refactoring katas I recommend.
- When to practice? We don't all have the luxury to take on our personal time to do so. But your employer certainly has to train you every year. They have a budget to spend on this! Use it to develop skills that will help you in the long run 😉
- What to practice? This is a very good question. Practicing is good, but it's better if someone can show you the moves…
When you're trying to learn new skills, it's a good idea to be looking for exposure to more experienced people on the topic.
If you're a visual learner, then it can be really helpful to see someone practice. Personally, it helps me understand how to apply techniques in front of actual code. Theory is good, but I prefer when it gets in contact with reality.
It's not easy to find good resources online on that very topic.
To help you save some time (and get you into practicing), here's my selection of 4 resources that will expose you to seasoned developers working their way through Legacy Code!
This one is in the "old, still gold" category 🏅
It shows you useful refactoring moves on the Trip Service kata, dropping some tips doing so.
I really like this one because Jovche is demonstrating how to behave in front of a code you never saw before.
A lot of good refactoring techniques are presented in these videos, including different approaches to the same problem.
You may already know Dave Farley. He's the co-author of "Continuous Delivery". You can tell he's a very seasoned developer.
In these 2 videos, he shows how to address Legacy Code. Specifically:
- Using Approval Tests to quickly cover existing code with tests
- Removing clutter from the code with basic refactorings
- Reducing complexity by extracting methods that got composed together
Gregor has a few videos like this on his channel.
I like how they are straight to the point and digestible. It shows you a technique (e.g. Subclass & Override) that you can reproduce on a refactoring kata I mentioned previously.
Do you have videos you recommend for learning to work with Legacy Code? Let us know in comments 👇