General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
Mikko Rantalainen
ThePrimeTime
comments
Comments by "Mikko Rantalainen" (@MikkoRantalainen) on "Wisdom From Linus | Prime Reacts" video.
After writing code for a couple of decades for living, I totally agree that DRY is about a compromise. I've come to conclusion that the rule should be "if you copy the same code to 3 different locations, you should fix the code". In addition, typically the best code can be created by first copy-pasting code, then writing the optimal solution for the task at hand using the copied code and then merging the copy-pasted code and the original code if that makes sense for long term maintanability. The only things that are important in long run are readability and maintainability. Changing the actual algorithm to more performant version is okay but micro-optimizations that make the code less readable are nearly never worth it. If you truly need to micro-optimize some inner loop, the code should come with a big f*cking comment block explaining why it's needed.
1