Aleksei Ivanov

Twilight zone of programming

Refactoring. The magic word. Maybe even mysterious.

Nothing compares to the joy that removing and carefully restructuring existing code brings to me. In fact, I love removing code.

Often times, the programs we create are too convoluted, too intertwined. Not necessarily because they are complex, but because it is hard to reason about a problem or because there is not enough time.

From my experience I’m starting noticing a pattern when it is pretty much impossible to design a system and write everything perfectly on the first attempt. This is when refactoring comes in: you cut down the fat after thinking long and hard about all the possible ways the feature can be implemented.

Ideally you do this not one or twice, but iteratively. The result is usually significant: lines of removed code, or even whole classes.

It’s like a compression algorithm for the reasoning and for abstractions that are used in the program. This is the twilight zone of programming: when the most creative part of you can run wild, when it’s important to listen to your inner feeling.

Because there are literally no formal rules on how to do this in the most efficient way.