Posts
1150
Comments
891
Trackbacks
1
Yes, Virginia, Code Reuse is Bad

Seems like this still comes up from time to time.

It happens in so many scenarios, but let’s focus this one on SQL code.  “Why are you rewriting that code, my code over here already does that!”

Is it identical code?

“Well, it’s very similar.  If you just use this code, then you don’t have to rewrite it, and we have fewer lines of code to maintain!”

And when you need to change your ‘very similar’ code, will you be prepared to retest every single other calling module to make sure your changes to your ‘very similar’ code don’t then break them?

“But if you just use this code, we won’t have code duplication!  Everyone knows code duplication is bad!”

Is it really duplication?  Are the business processes that drive that code being used absolutely identical, and unlikely to change?

Listen folks, the reason why code reuse is bad is because code ‘reuse’ is very rarely true reuse, and code ‘duplication’ is very rarely true duplication.

For those of you who like acronyms, avoiding SRP violations is (usually but not always) more important than avoiding code reuse.

posted on Thursday, September 19, 2013 8:20 AM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 3 and 4 and type the answer here: