In everyday life
Like clearing out a cupboard before you buy new things for it. Otherwise the new things go behind old tins that nobody uses, and you buy a second tin opener.
One case
A shop’s checkout has 3 discount systems, and one of them, from 2019, has had no users in 2 years. A developer adds student discounts and connects them to all 3, because nobody is sure which systems are still live. In March a customer finds that an old 2019 code still works, stacks it with a student code and pays $6 for a $40 order.
Before you add something new, remove what is dead or no longer needed. Then build on the simpler base.
Every case
Old code does not sit still. Every new feature must work alongside it, every reader must understand it, and every test must cover it. Dead codeCode that no part of the program runs anymore. It still costs reading time, and it can still be called by mistake. makes a system look more complex than it is, so new work gets connected to places it should never touch. Removing first makes the next change smaller, and it shows you what the system really does.
The word
Engineers call this
Delete what is dead before you build. Leave the code simpler than you found it.