3 ms·
Generic code is made to be copy-pasted. Also, what's wrong with copy-pasting when it lets you write features faster?
by glifchits 12y ago
Generic code is made to be copy-pasted. Also, what's wrong with copy-pasting when it lets you write features faster?
- StavrosK 12y agoIt's a code smell that usually means there's something there to be abstracted, or that your API isn't as clean as it could be.
- codeulike 12y agoI'd take a bit of copy-paste over premature generalisation any day.
- StavrosK 12y agoI'd take a premature generalisation over a false dichotomy.
- codeulike 12y agoSo if its not a dichotomy, what are the other options? If you want to avoid copy/paste, you have to use generalisation techniques.
- StavrosK 12y agoYes, and generalisation doesn't mean premature generalisation. It's very possible to just have a well-designed generalisation.
- codeulike 12y agoWell OK. But in a lot of cases I see badly designed over complex generalisations ("premature generalisation") because of a phobia of copy/paste. A bit of copy/paste is OK guys, seriously. Wait and see how it goes for a bit and then refactor the general case in later _if_ it seems worth it.