"You can say that again!" Duplication has been recognized for more than 30 years as the bane of the programmer's lot. How does duplication cause problems?
David Parnas introduced the idea of information hiding: A good module has a secret. By ensuring that a module keeps its secret, we usually reduce duplication. (See "On the criteria to be used in decomposing systems into modules," Communications of the ACM , 15 [2], 1972.) Duplication is a root problem. Many other smells are special-case indicators of duplication. Duplication is not always obvious, but it's critical that we address it. Strive to make your code express each idea "once and only once." |