PyCon Israel 2023 Workshop

Refactoring Without a Net
2023-07-05, 13:30–16:30, Room II

Refactor ugly legacy code, using design patterns for fun and profit


Code sucks. Well, not all code. If your code is clean, it doesn't. But for that to happen, you need to refactor all the time. But here's the catch: Refactoring without tests is risky. Without that safety net, you're not going to try. So, it's off to writing tests we go.

Unless, of course, there are other ways. Do you have some, Gil?

While there is no real replacement for tests, we can take shortcuts.

In this session, I will discuss refactoring, including examples of how to do it when you don't have tests but still don't want to bring the house down.

I'm going to talk about how to tackle different scenarios, understand the risks, and how refactor code that doesn't have actual tests. I will also show refactoring patterns using the lovely ApprovalTests open-source tool.

Refactoring may be risky, but it's not a yes/no option. You can still improve the code and make changes easier with these tips.