To eliminate information repetition of all kinds.
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system. Andrew Hunt and David Thomas (2000) The Pragmatic Programmer
This does not only apply to code:
- Copy-paste (surface features of the code are the same)
- Logical / Functional (the same logical process, but surface features vary)
- Data (the same information in two different places)
But also to:
- Documentation (requirements, for users etc.)
- Software architecture
- The software development process
To help you remember this practice, write out 100 times, “I will not repeat myself”.
- Repetition in process calls for automation
- Repetition in logic calls for abstraction
- Single Source of Truth (SSOT)
- Single Point of Truth (SPOT)
- Ignorance of parts of the system (I didn’t know it was already there!)
- Reliance on surface information rather then deep understanding. Assumption that is different because it looks different.
- Reuse of existing information from several non-colsolidated sources.
- Duplication requires that all copies must be maintained
- Leads to larger code / data base, making finding defects more difficult
- Automated derivation (eg. caches, generated code / documentation) where the original source is well know.
- Certain optimisation techniques
Part of Development Lifecycle
- Code reuse: Classes, subroutines, code libraries
- Data Normalisation
- Design Patterns