Hacker News new | ask | show | jobs
by sixothree 1923 days ago
I honestly thought that was one of the principles of DRY. Maybe I've been wrong this whole time. Will it be faster, safer, more maintainable if I just leave this code in here twice? At what point does that equation change?
2 comments

My approximate guideline is "is this copy and that copy of the code the same because they HAVE to be, or are they accidentally the same?"

If they absolutely have to be the same, wrap'em in a function. If they just happen to be the same, leave them as separate copies. If I don't know, make an educated guess.

Sure it is. However, teachers/mentors may be just a tad to dogmatic and pupils/juniors may just be a tad to inexperienced to properly grok when to do what.

And it sure is easier to just not argue about it and abstract everything. The real pain only comes later, after all.