Refactoring is a systematic process of improving codeRefactoring.guru
without creating new functionality that can transform
a mess into clean code and simple design.
With this lovely quote I want to present you my first Refactoring Challenge.
This challenge is derived from legacy code I’ve found in our repository from the year 2016. I created a fake environment around it (
FakeDatabase), so it works without any other components and then I uglified the code a little from experiences with code and merge requests I had in the past.
The challenge consists of two parts:
- Find all the little easter eggs/bugs. There might be some things that are not working and somehow haven’t been tested, plus some minor things regarding proper “code quality”. This first part is not yet about restructuring or refactoring the code! It’s more about finding all errors, debugging why they don’t work, and fixing them without rewriting the whole “application”.
Next week, you will get my solution with all the found bugs and how I solved them.
- After you’ve fixed all obvious bugs from the code, the second part of the challenge is to refactor the code. I will not give any hints on what might be the problem. My approach will be published in a few weeks. Although the repository is very very small, imagine this as a part of a big application with a lot of code. Keep this in mind when choosing your refactoring steps.
It would only be half as fun if everyone is doing the challenge on their own. So I invite you all to push your final solutions of part 2 as a Pull Request to the original repository so we can compare and discuss all the different solutions.