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 [2013-04-03 13:33] – [Evidence] christian | principles:don_t_repeat_yourself [2021-09-02 11:47] – old revision restored (2021-05-19 10:22) 65.21.179.175 | ||
---|---|---|---|
Line 26: | Line 26: | ||
===== 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 | ||
- | |||
- | ===== Caveats ===== | ||
- | |||
- | See section [[#contrary principles]]. | ||
Line 46: | Line 38: | ||
/* * [[wiki: | /* * [[wiki: | ||
- | * [[wiki: | + | * [[wiki: |
/* * [[wiki: | /* * [[wiki: | ||
Line 55: | Line 47: | ||
==== Generalizations ==== | ==== Generalizations ==== | ||
- | * [[Murphy' | ||
==== Specializations ==== | ==== Specializations ==== | ||
- | * [[Once And Only Once]] | + | * [[principles: |
- | * [[Single Choice Principle]] | + | * [[principles: |
- | * [[Write Code That Writes Code]]: This is the code generation aspect of DRY. | + | * [[principles:Single Choice Principle]]: |
+ | * [[principles:Write Code That Writes Code]]: This is the code generation aspect of DRY. | ||
==== Contrary Principles ==== | ==== Contrary Principles ==== | ||
- | * [[Keep It Simple Stupid]] | + | * [[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 ==== | ||
Line 76: | Line 67: | ||
{{page> | {{page> | ||
- | ===== Examples | + | ===== Example |
principles/don_t_repeat_yourself.txt · Last modified: 2021-10-18 21:27 by christian