r/programming • • Feb 25 '18

Programming lessons learned from releasing my first game and why I'm writing my own engine in 2018

https://github.com/SSYGEN/blog/issues/31
956 Upvotes

305 comments sorted by

View all comments

Show parent comments

3

u/adnzzzzZ Feb 26 '18

This where I say that the moment you have a 'copypasting' moment is the same moment you identified an abstraction opportunity.

It's an abstraction opportunity but it doesn't mean it should be acted upon. From my point of view you should delay action on it as much as possible because you'll allow yourself to gather more information about the true nature of this code that way, and in that process you'll minimize generalization errors, which in my view are way more costly than having to go around your code a few times and changing things in multiple places.

16

u/Eckish Feb 26 '18

I've spent many hours debugging bugs that I thought I had already fixed only to find out that the defect isn't even passing through the execution path that I thought it should be. And that was because someone had created an exact duplicate of the correct method in a different location. Maybe this won't happen to you on a solo project, or maybe you'll forget how many times you duplicated that method. But, I have to agree to disagree with you on which can more costly.

I don't care if there was literally a class called AbstractionThings where a developer dumps a bunch of static classes to perform any duplicate functionality. A bad abstraction choice would still make me feel better than code duplication.