Hacker News new | past | comments | ask | show | jobs | submit login

Duplication is fine until it gets out of hand, at which point you'll be able to identify the right abstraction.



Yeah. I'd agree with this. I've had to maintain some terrible codebases with duplication everywhere. The truth is, I have an easier time fixing bugs in simple but duplicated code than I do fixing bugs in super abstract but DRY code. Which has me thinking: clear, obvious code with duplication is better than magic code which is DRY.

Obviously, the best is DRY, obvious, and explicit...

Also, a rule of thumb is premature optimization is bad. So is premature abstraction.


This is an very important concept, "premature abstraction is bad"


Then you're in the situation that your code is a mess of copy-paste and its obvious what you should do, but management prefers that you work on features instead of changing "proven, reliable" code. Thus the mess is there to stay.


That bad culture is a separate problem which will make everything worse.

In your case, it seems mixed - while you do have to update code in multiple places the flip side is that you can more confidently change code in one location without breaking something else. If you're on a death-match piling up technical debt, that might be less painful than dense inter-connected code, albeit still worse than working somewhere with more long-term thinking.


Yeah, picking the wrong abstraction too early also gives you "proven, reliable" code that's sometimes even harder to maintain.

First example of this that occurs to me was an old Rails app I took over. We needed to migrate it up to modern versions of Ruby and Rails since it was getting harder and harder to support the old ones, and they were about to hit their maintenance end of lifes, but someone had extended the Rails framework stuff with their own extra layer.

Now we had code that changed subtly with a new version of Ruby that was used in dozens of places for actually-somewhat-different things, so the fixes had to account for all those different ways it was being used too. Not a lot of fun, you can fix one endpoint but then have to make sure you don't re-break it with how you fix the next one...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: