Refactors That Pay Rent
Refactoring doesn’t have to be a heroic saga. Some of the best refactors are the boring ones—the kind that quietly make everything easier.
1) Name the thing
If a block of code needs a comment to explain what it is, it probably needs a function name.
2) Collapse boolean pyramids
Prefer early returns over nested conditionals. Your future self will thank you with fewer headaches.
3) Make data shape obvious
If you’re passing around objects with “maybe this field exists?” energy, define a type (or schema) once and reuse it.
4) Split side effects from pure logic
One function that fetches data, transforms it, and writes it to disk is hard to test. Three smaller functions are usually easy.
5) Delete dead code aggressively
Dead code isn’t “just in case.” It’s an invitation to misunderstand the system.
Keep refactors small. Ship them. Repeat. That’s the real compounding.