From legacy code to modern code

Date
Type
Talk
Language
English
Length
30 minutes

About this talk

Starting a new project is fun. But what about an existing project consisting of big monolithic legacy code in Python 2 that has no tests and breaks often? Would you start from scratch to rebuild this project? We decided to do it the opposite way - we started to change our current code a step by step. Refactoring the old code was a hard time full of trials and errors. From the beginning, we could only rely on weak monitoring to reveal bugs or not properly working service. We ended up in a position where new release would put us in the risk, and we were afraid to do it. Enhanced monitoring allowed us to stabilize the service until we were able to add tests. With every small improvement our confidence rose, maintenance became easier and adding new features became smoother. Finally, we were ready for the biggest step - switch to Python 3. After a year full of preparations, this exciting and successful work took us only a few days. But we did not stop there. We needed to improve the architecture and break the monolith to single-purpose packages, which we could connect via dependency injection. We followed the SOLID principles which allowed us to make better tests and to make our code more flexible to big changes.