this post was submitted on 20 Dec 2024
96 points (92.9% liked)

Programming

17680 readers
54 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
 

DRY = Don't repeat yourself

you are viewing a single comment's thread
view the rest of the comments
[–] robinm@programming.dev 2 points 5 days ago

I personally factorize as soon as there are two copies, but do not hesitate to inline the code and redo the abstraction when there is a 3rd use if it doesn't fit. I find it much easier to inline and re-abstact a bad abstraction, than check if two copies are indeed identical.

The exception is business logic. Usually I want all of them to be dupplicates because there is a very high chance that it's just accidental that part of the logic is similar. I take great care to have good primitives but the actual business logic that glue those primitives together is written as many time as needed.