Duplicate code is the root of all evil !
My retort suggests that there is a greater root of all evil: Duplicated code.
Quoting wikipedia: ( should I say duplicating wikipedia )
The DRY principle is stated as "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." The principle has been formulated by Andy Hunt and Dave Thomas in their book The Pragmatic Programmer. They apply it quite broadly to include "database schemas, test plans, the build system, even documentation."1 When the DRY principle is applied successfully, a modification of any single element of a system does not require a change in other logically unrelated elements. Additionally, elements that are logically related all change predictably and uniformly, and are thus kept in sync. Besides using methods and subroutines in their code, Thomas and Hunt rely on code generators, automatic build systems, and scripting languages to observe the DRY principle across layers.
The DRY Principle: Don't repeat yourself (wikipedia page):
Here's another link. An article
And related books:
- "The Pragmatic Programmer" by Andrew Hunt, David Thomas
- "Refactoring: Improving the Design of Existing Code" by Martin Fowler, Kent Beck, John Brant, William Opdyke, Don Roberts
- "Clean Code: A Handbook of Agile Software Craftsmanship" by Robert C. Martin