News for hackers. Stuff that matters.
Re:Don't DRY Your Code Prematurely by wnevets on Thursday May 30, 2024 @04:32PM (#40528298)
> So we had twice the code we needed.

Was that necessarily a bad thing and something that must be corrected for that code base?

I usually follow the same rule of thumb until I find myself repeatedly updating both at the same time. If I can't update one without updating the other then they must be the same thing and its time to DRY.

Don't Repeat Yourself when updating code.

Re:Don't DRY Your Code Prematurely by Stratoscope on Thursday May 30, 2024 @04:43PM (#40528462)
Good points, thanks for bringing them up.

Yes, there was some ongoing maintenance of this code where both versions had to be updated. The original author was not a pilot and was unfamiliar with some of the nuances of FAA airspace. One of the reasons they brought me in was that I am a pilot and knew how the FAA's data should be interpreted.

In the end, not a huge deal, but it was annoying when I had to make the same changes in two places.

Re:Don't DRY Your Code Prematurely by thdc on Thursday May 30, 2024 @04:58PM (#40528648)
Knowing to DRY there depended on business knowledge that the original author did not have.

While they were wrong in this case, I would say it was a reasonable move to not DRY based on the code pattern itself at the time. And that's the big difference imo - DRYing based strictly on the structure of code vs business processes.

Re:Don't DRY Your Code Prematurely by chii on Thursday May 30, 2024 @09:57PM (#40530718)
But this implies that you have to guess when and where to DRY, which basically implies that there's no good way but via experience and domain knowledge!

That's not what people want to hear - they want a silver bullet; a set of criteria for which DRY'ing could be determined from the onset!