Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

When I do code necromancy, instead of understanding the code, I try to understand what it does, how it interacts with the world, and then recreate that behavior.

Meaning I capture all the I/O and recreate it. SQL, HTML, PDF, CSV, whatever. Serialize everything, before and after. And then do diffs on the outputs to see if new code reproduces expected behavior.

Much easier than dead code removal, code deduping, incremental changes, backfilling tests, etc.

Once someone captures, documents what the code is actually doing, the real refactoring begins. Removing unnecessary queries. Grooming data. Simplifying schemas. Aligning the app with the biz. Etc.



This is often the only sane thing to do.

It’s my default approach with thorny scientific code: get everyone to agree on what output should be for a bunch of relevant inputs, get the original systems output, hash it, and then write a bunch of tests in a new project that all assert that these inputs produce outputs whose hashes are as follows..

then never look at the guts of the horror again.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: