In Favour of Copy-and-Paste code

— 1 minute read

Say what?

Advocate: If we want to execute the same thing in more than one place, we should copy and paste the code.

Blasphemy!

Increasing Duplication to Eliminate Duplication 

Not quite, according to Eugene Wallingford - so long as it is an intermediate step. The premise is that the more identical the duplication is, the easier it is to spot the refactor required.

Upon reflection, I can think of many cases where I have, unwittingly, done this for the more difficult problems requiring refactors.

Writing code, is such a fascinating exercise in abstract thought, that every now and then, you realise that you had developed and used thought patterns. Subconsciously, no less. The delight that comes from each of these realisations is on par with the ones that one gets during the epiphany of an “Aha!” moment.