68
top 13 comments
sorted by: hot top controversial new old
[-] KissYagni@programming.dev 57 points 3 days ago* (last edited 3 days ago)

"Bad abstraction is worse than duplication"

Oh shit, thank you so much for this part ! I don't even count number of time I had to face enthusiasts developers saying "These lines of code are very similar, let's factorize them ! "

And that's how MathManagerHelper class is born...

[-] atzanteol@sh.itjust.works 19 points 3 days ago

God yeah - this hits hard with me. I work in a place where the DRY principle is chanted like a mantra and I have to push back against it constantly. It's like the one principle jr. devs learn (along with "never hardcode anything") that just gets applied to everything whether it makes sense or not.

"These lines of code are very similar, let’s factorize them ! "

"We should take three simple functions that run similar (but different) things and make them call a single large complicated function that takes a parameter that tells it how to execute!"

::shudder::

[-] Hasherm0n@lemmy.world 2 points 2 days ago* (last edited 1 day ago)

You just reminded me of the early days at a company I worked where the factory pattern was absolute. There were interfaces and factories for fucking DTOs. It was insanity! That was the place where I really learned the concept of "cargo cult"

[-] buffing_lecturer@leminal.space 3 points 2 days ago

What pattern should be used instead?

[-] atzanteol@sh.itjust.works 4 points 2 days ago

"The one that makes sense"

Patterns and principles are guidelines, not rules. You don't want to just apply them blindly.

You need to balance principles. Over-applying the DRY principle can lead to more complex logic that's harder to understand than if you just wrote code in-line.

[-] fruitycoder@sh.itjust.works 4 points 2 days ago

The rule I see is functions should be fairly atomic and almost obvious what they do in context of the code.

At least for my small brain that's how I like it. I can understand some complex abstractions but rembering that actually this function behaves in three different ways depending on what flag is set is awful. It means you could look at one example and be totally wrong in another. Ideally you could guess the functions purpose even in a black box setting based on inputs outputs and the name should then make it obvious.

[-] buffing_lecturer@leminal.space 3 points 2 days ago

The example that the other commenter gave did not require the user to input the flags. As far as I understand, they mean there would be a number of secondary functions that will call the other with the correct parameter.

[-] fruitycoder@sh.itjust.works 3 points 2 days ago

Fair point. My point still stands on it breaking the black box test. Where the input can wildly effect the logic that creates the output.

[-] Kissaki@programming.dev 1 points 1 day ago

Struggling with Legacy Code and not enough time to clean it up?
⛑️️ My First Aid Kit can help you rescue any codebase quickly and safely!

"rescue any codebase quickly and safely"? [x] doubt

But who knows what "rescue" means for them.

[-] 30p87@feddit.org 18 points 3 days ago
[-] iamtherealwalrus@lemmy.world 14 points 3 days ago

I would say: Learn to use LLMs as a tool rather than a crutch.

[-] masterspace@lemmy.ca 15 points 3 days ago* (last edited 2 days ago)

+++ I cannot stress this enough.

Programmers tend to get over obsessive about DRY code because it seems like it should be easier to maintain fewer functions and writing less code should be easier right? But it tends to ignore the actual subtle differences between the different consumers of that abstraction, and that leads to massively branching functions that couple unrelated parts of the codebase together. These then become impossible to read and change without worrying about breaking something else.

When I was at Thoughtworks (Martin Fowler's current company), we were also taught the rule of three for refactoring, and were taught to always optimize your code for readability and maintainability first and foremost. Refactoring and improving easy to read/maintain code is always relatively trivial, by nature of it being clear, concise and decoupled, and that can be done once you have a reason to do so (i.e. performance issue etc), so there's no point over optimizing for anything else up front.

This talk from Dan Abramov (one of the lead devs of React) does a really really good job explaining some of these issues and is entirely worth the full watch/listen (do it on company time, it's professional development):

https://www.deconstructconf.com/2019/dan-abramov-the-wet-codebasets

[-] DoctorNope@lemmy.world 10 points 3 days ago

My rule of three: consider rewriting any article, blog, exhortation, argument, leaflet, or wiki page that uses more than three fonts, sizes, colors, or styles.

this post was submitted on 10 Oct 2025
68 points (97.2% liked)

Programming

23074 readers
116 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