principles:don_t_repeat_yourself
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
principles:don_t_repeat_yourself [2021-09-02 11:46] – old revision restored (2021-05-19 10:22) 65.21.179.175 | principles:don_t_repeat_yourself [2021-09-02 11:47] – old revision restored (2021-05-19 10:22) 65.21.179.175 | ||
---|---|---|---|
Line 10: | Line 10: | ||
* [[contexts: | * [[contexts: | ||
- | ===== Principle Statement | + | ===== Definition |
> "Every piece of knowledge must have a single, unambiguous, | > "Every piece of knowledge must have a single, unambiguous, | ||
Line 24: | Line 24: | ||
If there are several representations of the same information (be it code or any other form of information), | If there are several representations of the same information (be it code or any other form of information), | ||
- | |||
- | ===== Strategies ===== | ||
- | |||
- | * Add a new invokable module (a function, a method, a class, etc.) instead of duplicating code | ||
- | * Use code generation when information has to be represented in multiple forms | ||
- | * Use polymorphism to avoid repeatedly enumerating a set of possible solutions in if or switch statements | ||
===== Origin ===== | ===== Origin ===== | ||
Line 38: | Line 32: | ||
===== Evidence ===== | ===== Evidence ===== | ||
/* Comment out what is not applicable and explain the rest: */ | /* Comment out what is not applicable and explain the rest: */ | ||
- | /* | + | / |
- | /* | + | / |
- | + | [[wiki: | |
- | * [[wiki: | + | / |
- | + | ||
- | /* | + | |
Line 50: | Line 42: | ||
==== Generalizations ==== | ==== Generalizations ==== | ||
- | * [[Murphy' | + | * [[principles: |
==== Specializations ==== | ==== Specializations ==== | ||
- | * [[Once And Only Once]] | + | * [[principles:Once And Only Once]]: This is the aspect of DRY which is concerned with the avoidance of (code) duplication. |
- | * [[Single Choice Principle]] (SCP): Duplication can also be duplication of information about a set of possibilities. The SCP is about this aspect. | + | |
- | * [[Write Code That Writes Code]]: This is the code generation aspect of DRY. | + | |
==== Contrary Principles ==== | ==== Contrary 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 Principles ==== | ==== Complementary Principles ==== | ||
- | * [[Generalization Principle]] (GP): A generalized solution avoids duplication. | ||
==== Principle Collections ==== | ==== Principle Collections ==== | ||
- | {{page> | ||
- | {{page> | ||
===== Example ===== | ===== Example ===== | ||
Line 86: | Line 73: | ||
* [[wp> | * [[wp> | ||
* [[http:// | * [[http:// | ||
- |
principles/don_t_repeat_yourself.txt · Last modified: 2021-10-18 21:27 by christian