← Back to context

Comment by motorest

1 year ago

> I work with someone who has a habit of code duplication like this.

Are you sure it's code duplication?

I mean, read your own description: the new function does not need to support edge cases. Having to handle edge cases is a huge code smell, and a clear sign of premature generalization.

And you even admit the guy was more productive and added less bugs?

There is a reason why the mistakes caused by naive approaches to Don't Repeat Yourself (DRY) are corrected with Write Everything Twice (WET).

I didn’t say less bugs. There are a lot of bugs, they are just localized to each call, and then copy/pasted all over the place. So when found, they need to be fixed in a bunch of places. It makes for quite the mess.

They just aren’t making changes to the shared function, so they don’t need to test existing functionality still works, just their single use case.