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:47] – old revision restored (2021-05-19 10:22) 65.21.179.175 | principles:don_t_repeat_yourself [2021-09-02 17:48] – old revision restored (2021-05-11 19:02) 65.21.179.175 | ||
---|---|---|---|
Line 27: | Line 27: | ||
===== Strategies ===== | ===== 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 | + | ===== Caveats |
- | Andrew Hunt and David Thomas: //[[http:// | + | See section |
+ | ===== Origin ===== | ||
+ | |||
+ | {{page> | ||
===== Evidence ===== | ===== Evidence ===== | ||
/* Comment out what is not applicable and explain the rest: */ | /* Comment out what is not applicable and explain the rest: */ | ||
/* * [[wiki: | /* * [[wiki: | ||
- | /* * [[wiki: | ||
- | * [[wiki: | + | |
+ | | ||
/* * [[wiki: | /* * [[wiki: | ||
Line 47: | Line 53: | ||
==== Generalizations ==== | ==== Generalizations ==== | ||
+ | * [[Murphy' | ||
==== Specializations ==== | ==== Specializations ==== | ||
- | * [[principles: | + | * [[Once And Only Once]] |
- | * [[principles: | + | * [[Single Choice Principle]] |
- | * [[principles:Single Choice Principle]]: | + | * [[Write Code That Writes Code]]: This is the code generation aspect of DRY. |
- | * [[principles:Write Code That Writes Code]]: This is the code generation aspect of DRY. | + | |
==== Contrary Principles ==== | ==== Contrary Principles ==== | ||
- | * [[principles:Keep It Simple Stupid]]: Especially code generators can be very complex. | + | * [[Keep It Simple Stupid]] |
==== Complementary Principles ==== | ==== Complementary Principles ==== | ||
+ | * [[Generalization Principle]] (GP): A generalized solution avoids duplication. | ||
==== Principle Collections ==== | ==== Principle Collections ==== | ||
Line 67: | Line 74: | ||
{{page> | {{page> | ||
- | ===== Example | + | ===== Examples |
===== Description Status ===== | ===== Description Status ===== | ||
/* Choose one of the following and comment out the rest: */ | /* Choose one of the following and comment out the rest: */ | ||
- | [[wiki: | + | /*[[wiki: |
- | /*[[wiki: | + | [[wiki: |
/ | / | ||
principles/don_t_repeat_yourself.txt · Last modified: 2021-10-18 21:27 by christian