Great article! The only thing I have to say is that I'm one of those people who says that repeating something twice isn't enough to justify abstracting it out just for the sake of being DRY. In only the most simple programs will something that you use a third time be exactly the same as the first two times you did it. Waiting until you've repeated yourself three times helps you know what it is that you're actually repeating.
Silicon Forest Developer/hacker. I write about Generative AI, DevOps, and Linux mostly.
Once held the world record for being the youngest person alive.
I can live with that. I usually stop and abstract when I find myself repeating something the 2nd time because I don't want it to spiral out of control. I've been criticized in code reviews for abstracting too much into methods, some of them only having one or two lines. I abstract things early which may be repeated... that arguably can be another form of YAGNI lol.
But I do like the "do one thing and do it well" philosophy. 3 times is reasonable.
Versatile software engineer with a background in .NET consulting and CMS development. Working on regaining my embedded development skills to get more involved with IoT opportunities.
Context is crucial too...you can have the same code show up in different places with completely different contexts which looks repetitive, but it makes no sense to de-duplicate something that crosses system boundaries.
Silicon Forest Developer/hacker. I write about Generative AI, DevOps, and Linux mostly.
Once held the world record for being the youngest person alive.
Absolutely right. Sometimes you can have the exact code verbatim and working off two different input/outputs. One of those implementations may change without the other so by de-duping and putting into a method you can be creating a regression.
This is why software engineering is so fun! (not saying it sarcastically)
Hi 👋
I'm Jesco, software consultant, digital nomad and currently trying to build my own learning platform.
If you have any feedback please tweet at me @jescowuester
Silicon Forest Developer/hacker. I write about Generative AI, DevOps, and Linux mostly.
Once held the world record for being the youngest person alive.
Great article! The only thing I have to say is that I'm one of those people who says that repeating something twice isn't enough to justify abstracting it out just for the sake of being DRY. In only the most simple programs will something that you use a third time be exactly the same as the first two times you did it. Waiting until you've repeated yourself three times helps you know what it is that you're actually repeating.
I can live with that. I usually stop and abstract when I find myself repeating something the 2nd time because I don't want it to spiral out of control. I've been criticized in code reviews for abstracting too much into methods, some of them only having one or two lines. I abstract things early which may be repeated... that arguably can be another form of YAGNI lol.
But I do like the "do one thing and do it well" philosophy. 3 times is reasonable.
Context is crucial too...you can have the same code show up in different places with completely different contexts which looks repetitive, but it makes no sense to de-duplicate something that crosses system boundaries.
Absolutely right. Sometimes you can have the exact code verbatim and working off two different input/outputs. One of those implementations may change without the other so by de-duping and putting into a method you can be creating a regression.
This is why software engineering is so fun! (not saying it sarcastically)
duplication is better than the wrong abstraction :D
most of the time, yes