Thursday, December 15, 2011

Cut and Paste is not a valid design pattern

You would think in this day and age, that no-one would copy a 200 line function from one class to another.

Because if they did then surely one version would have changes made to it.

Then some poor fool would be left wondering if the two versions were actually slightly different, or if a fix was applied to one, not the other. Or if a change was simply because the functions were called in slightly different ways.

Of course having a 200 line function which looks like 20 x 10 lines blocks cut and paste into a switch statement... that would be a wrong thing in the first place.

And no-one would do that, because if they did, their name would be against the check-in in the source code control system.

No comments:

Post a Comment