What is Legacy Code?
There are several interpretations of what Legacy Code is (see Wikipedia - Legacy Code. From most definitions you can normally extract two characteristics that Legacy Code may have:
- Old. Code that was inherited from someone else or from an old version of the software and that is no longer supported.
- Ugly. Code that developers are afraid to change and/or isn’t covered by tests.
If it’s just old code, the main problems to tackle are usually complexity, lack of documentation and security vulnerabilities. If it’s ugly, the code is probably causing many bugs (not covered by tests) and frustration amongst developers.
In any case, organizations usually want to get rid of Legacy Code because it’s difficult to maintain and causes a waste of money and resources.
How to get rid of Legacy Code?
When dealing with Legacy Code, people normally find themselves in one of these categories:
- The Broken Windows theory (wiki). While modifying something within the Legacy Code boundaries, you prefer to follow (copy-paste) the same existing anti-patterns (even if you write new functionality). You don’t feel like changing the way the code looks like since you don’t know where to start from.
- Jenga Development. Whenever you need to add new functionality, you do it nicely but you leave the old code as-is. You are in a cold sweat, trying not to touch those code blocks because they have no automated tests and you don’t want to take the risk of breaking existing functionality, unaware of what that code does.
- The Boy Scout Rule. While you are adding a new functionality inside Legacy Code, you take some time and improve it, making it more readable, creating tests or avoiding some future bugs.
- The Cowboy Way. You decide to go on an adventure and refactor the Legacy Code without thinking too much about the impact. That action implies massive changes across multiple packages/classes/modules. It takes two weeks before you have something that works as before. When you’re about to merge it, you need another two weeks because others have been merging new code following one of the other approaches above. Finally, after you merge it, you get multiple complaints related to other parts of the system not working as before.
These approaches are a bit exaggerated. But you can surely recognize the four strategies:
- Creating more legacy.
- Not touching the legacy.
- Getting rid of it, a bit each time.
- Getting rid of it, all at once.
The Boy Scout Rule is clearly the best technique, but sometimes is not enough. If the technical debt that is slowing you down is spread across your codebase or it’s part of the core implementation, you need to wear your Cowboy hat sometimes. If you follow the “Broken Windows” or “Jenga” styles, you have a serious problem and you better deal with it as soon as you can.
Motivation and Legacy Code
As a software developer, the feeling of not having to deal anymore with error-prone code is great. Your scripts or classes look good and readable. Nobody needs to waste time anymore in explaining how that old code works, or testing features manually, or fixing bugs caused by the technical debt.
However, even though the final result gives a boost of motivation, the process of getting there is not so encouraging. To accomplish it step by step, you may need to introduce some tricks here and there or have a partially-fixed codebase that may look even worse than before. Furthermore, you need to have a clear commitment that you will finish the refactoring task or the team will feel that they are wasting their time.
Quboo helps you get rid of Legacy Code. It makes the refactoring task a team effort and it encourages everybody to get rid of that anchor that is dragging the team.
Get rid of Legacy Code with Quboo
Quboo is a platform that you can use to spice up the process of dealing with Legacy Code by introducing some gamification ingredients. It helps in several ways:
- Makes Legacy Code visible to everybody. Quboo uses a score that is based on the amount of technical debt hours, which is directly related to Legacy Code. Therefore, it provides a clear metric and the feeling of progress that developers and managers are missing. For even better results, display the rankings on screens in your office.
- Defines a Goal. Set up a date in future to finalize your Campaign for improving Legacy Code. Offer something to the winners as an extra ingredient for fun: think of symbolic trophies like mugs, t-shirts, etc.
- Leverages collaboration. The fact that you are supported by a lightweight game is a powerful way of getting together to fix the problem. Without the game, this kind of tasks end up lost in the backlog.
Once you finish the first iteration, check with everybody how was the experience and, if you want to try again, define a new goal and start back again. You can re-define the Legacy Date if you need it, and restart all the scores so everybody can catch up. You can do that by using the corresponding options under the Settings section from Quboo’s web interface.