The most satisfying thing to do with source code
Delete it.
And I don't just mean deleting bad code, in the same sense as you might enjoy clearing junk from your yard. I think it's even more satisfying to delete code that you like, that you had a hand in creating, that you feel proud of.
Deleting good code makes sense either when circumstances have changed so that it is no longer required, or when the code has served as a stepping stone but will not be used in the final solution.
Pseudo-examples
Changing Business
- Write code to solve a business problem
- Deploy the code into production and use it to run the business
- Change the business, possibly due to a short term business opportunity
- Delete the redundant code
Exploratory Test
- Write a unit test to express how a part of the system should operate
- While trying to make the test pass, discover a different abstraction that will be easier to test and implement
- Write new tests and implementations using the new abstraction
- Delete the original unit test
Refactoring Pontoon
- Attempt a refactoring that is too large to complete in one step.
- Write pontoon code, possibly many new classes, that will keep the system in a working state while the refactoring is in progress.
- Complete the large refactoring after several steps
- Delete the pontoon code
Deleting "perfectly good" code might seem wasteful, but going down that road is going bring you to the old fallacies about predicting programmer productivity by measuring their typing speed.
I've started to realise I feel proud when I delete good code, with an environmentally friendly kind of smugness. Hopefully I'm doing my bit to reduce my complexity footprint on the software landscape.