re: What programming best practice do you disagree with? VIEW POST

FULL DISCUSSION
 

DRY is a goal unto itself or Copying and Pasting Code is BAD!

My mantra is, don't try to DRY before you are WET (Writing it Every Time).

Having good tests can go a long way towards ensuring duplicated code continues to function correctly after modifications.

And consolidating duplicated code too early can result in an abstraction that serves too many roles.

Different parts of your code will change at different speeds and for different purposes. If you force two parts to change at the same speed and for the same purpose even if they wouldn't had they not been DRY'd up, you will box yourself into corners that are hard to get out of.

Look for the patterns in your code before you start consolidating replication.

Let your application's patterns reveal themselves to you naturally instead of trying to force them prematurely under the banner of "DRY".

code of conduct - report abuse