this post was submitted on 20 Dec 2024
94 points (94.3% liked)
Programming
17666 readers
374 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
First off, I generally don't worry about DRY until there are 3 instances, not 2. With only 2, it's really easy to over-generalize or have a bad structure for the abstraction.
But otherwise, I disagree with the article. If it's complicated enough to bother abstracting the logic, the worst that can happen in the above situation is that you just duplicate that whole class once you discover that it's not the same. And if that never happens, you only have 1 copy to maintain.
The code in the article isn't complicated enough that I'd bother. It even ends up with about the same number of lines of code, hinting that you probably haven't simplified things much.
Yeah, I'm reminded of how Germanic languages used to have singular, dual and plural. If we'd still had dual, we'd probably also be talking about not abstracting until we actually have a plural.