3 ms·
Slowly and carefully, like you're defusing a malfunctioning clockwork bomb. 1) Understand at a very fundamental level what it does (there are probably multiple
by falcolas 11y ago
Slowly and carefully, like you're defusing a malfunctioning clockwork bomb.
1) Understand at a very fundamental level what it does (there are probably multiple things).
2) Understand at a very fundamental level what it does (this is really the hard part)
3) Document your hard-earned understanding (tests, ironically, do not work well for this, since there are no fundamental units to test at, and there likely is a metric ton of shared state)
4) Refactor it into something easier to understand and test.
I've had to work with a similar 5,000 line C function at the heart of a DSL parser; literally the core of the entire business. Changes were made very slowly, and with a lot of consideration. Refactoring is still underway 6 years later.