Good Coders Code, Great Coders Reuse

Not sure where the saying "good coders code, great coders reuse" came from but I sure been doing a lot of copy-pasting throughout my 4+ year career. Web apps, mobile, games, blogger code,  etc. All stuff that I've been doing, I've always been doing a lot of copy-pasting code. Yes, copy-pasting is code reuse. In fact, I rarely really encounter code reuse in object oriented programming... Unless I'm using a framework, I rarely even really extended a class and "reused" anything from that class. Well... I've been able to apply the reuse of default behavior more in games than in web projects.

I notice that even when this is put to practice, there was a struggle trying to maintain different version of jar files or assemblies throughout a distributed development team. Even static methods used for utility classes are duplicated across the entire codebase. The only real thing being reused is the functionality. If I wrote a class method that writes something to a file, chances are I've also only looked that up on the internet and "re-used" somebody else's code.

Published 04-26-2010 1:31 AM by lamia

Comments

Monday, April 26, 2010 3:04 PM by LaTtEX

# re: Good Coders Code, Great Coders Reuse

Convincing one's self that copy-pasting code is code reuse is one of the classic mistakes a programmer transitioning from novice to intermediate always makes.

The biggest part of that mistake is the foregone conclusion that "OOP doesn't work for me", lamenting that to be able to truly reuse code they still had to resort to copy-pasting or reimplementing functionality in several places.

This is a conundrum faced during the time where a developer is yet to be familiar with how design patterns really come into play in frameworks, and how design patterns simply emerge from the code (as opposed to being applied a la cookbook) while refactoring that framework or API towards more efficient and heavy reuse.

I have had way too many experiences where simple copy pasting in huge applications caused maintenance headaches simply because we needed to chase for each and every copy-pasted instance of "re-use" to reflect changes in requirements. Perhaps when you experience that pain point you will begin to understand that while copy pasting has its place (e.g., utility classes, where they are totally fine) that place shouldn't be all too huge in your programming arsenal.

Monday, April 26, 2010 9:23 PM by lamia

# re: Good Coders Code, Great Coders Reuse

Thanks for sharing your thoughts LaTtEX.

Ofcourse, OOP works for me and I don't deny how design patterns have helped me solve certain problems or improve certain scenarios.

I also appreciate how design patterns are used in frameworks and the importance in understanding them to fully utilize a framework.

However, when solving certain problems... I don't mind using copy-pasted code just to see how something or if something will work. If it works then I strive to find a better solution. Or maybe, just leave it like that for the moment until I find a better solution.