User Tools

Site Tools


principles:don_t_repeat_yourself

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
principles:don_t_repeat_yourself [2012-11-27 09:18] – [Origin] link christianprinciples:don_t_repeat_yourself [2021-09-02 11:47] – old revision restored (2021-05-19 10:22) 65.21.179.175
Line 1: Line 1:
 ====== Don't Repeat Yourself (DRY) ====== ====== Don't Repeat Yourself (DRY) ======
  
-===== Alternative Names =====+===== Variants and Alternative Names =====
  
   * Single Point of Truth (SPOT)   * Single Point of Truth (SPOT)
Line 8: Line 8:
 ===== Context ===== ===== Context =====
  
-  * [[contexts:Software Design]]+  * [[contexts:Object-Oriented Design]]
  
- +===== Definition =====
-===== Description =====+
  
 > "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system."((Andrew Hunt and David Thomas: //The Pragmatic Programmer: From Journeyman to Master//; see [[http://pragprog.com/the-pragmatic-programmer/extracts/tips|List of Tips]].)) > "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system."((Andrew Hunt and David Thomas: //The Pragmatic Programmer: From Journeyman to Master//; see [[http://pragprog.com/the-pragmatic-programmer/extracts/tips|List of Tips]].))
 +
 +
 +===== Description =====
  
 DRY not only states that code duplication shall be avoided. Rather DRY is a general rule that states that if there is duplication, there shall be some "single source of truth". Also when one piece of information has several representations (like an object structure corresponding to a database schema) DRY demands one and only one representation being the definitive one. The other representations have to be generated automatically. The "one and only" representation can be one of the used representations or alternatively a third one. DRY not only states that code duplication shall be avoided. Rather DRY is a general rule that states that if there is duplication, there shall be some "single source of truth". Also when one piece of information has several representations (like an object structure corresponding to a database schema) DRY demands one and only one representation being the definitive one. The other representations have to be generated automatically. The "one and only" representation can be one of the used representations or alternatively a third one.
Line 29: Line 31:
  
 ===== Evidence ===== ===== Evidence =====
- +/* Comment out what is not applicable and explain the rest: */ 
-Widely accepted: It is generally agreed upon that code duplication is to be avoided. On the other hand the broader meaning of DRY which results in the heavy use of code generators is often not considered.+/*[[wiki:Proposed]]*/ 
 +/*[[wiki:Examined]]*/ 
 +[[wiki:Accepted]]: It is generally agreed upon that code duplication is to be avoided. On the other hand the broader meaning of DRY which results in the heavy use of code generators is often not considered. 
 +/*[[wiki:Questioned]]*/
  
  
 ===== Relations to Other Principles ===== ===== Relations to Other Principles =====
  
-==== Specialization of ====+==== Generalizations ====
  
-  * [[principles:Generalization Principle]] 
  
-==== Generalization of ====+==== Specializations ====
  
-==== Contrary to ====+  * [[principles:Generalization Principle]] A generalized solution avoids duplication. 
 +  * [[principles:Once And Only Once]]: This is the aspect of DRY which is concerned with the avoidance of (code) duplication. 
 + 
 +==== Contrary Principles ====
  
   * [[principles:Keep It Simple Stupid]]: Especially code generators can be very complex.   * [[principles:Keep It Simple Stupid]]: Especially code generators can be very complex.
  
-==== Complementary to ====+==== Complementary Principles ====
  
-==== Part of the Following Principle Collections ====+ 
 +==== Principle Collections ====
  
  
Line 54: Line 62:
  
 ===== Description Status ===== ===== Description Status =====
 +/* Choose one of the following and comment out the rest: */
 +[[wiki:Stub]]
 +/*[[wiki:Incomplete]]*/
 +/*[[wiki:Complete]]*/
 +
  
-Stub +===== Further Reading =====
  
 +  * [[wiki>DontRepeatYourself]]
 +  * [[wp>Don't repeat yourself]]
 +  * [[http://programmer.97things.oreilly.com/wiki/index.php/Don't_Repeat_Yourself|97things: Don't_Repeat_Yourself]]
principles/don_t_repeat_yourself.txt · Last modified: 2021-10-18 21:27 by christian