Skip to content

Commit 51e9694

Browse files
committed
Move DRY down a bit
1 parent 9f54c9a commit 51e9694

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

README.md

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ have any feedback or suggestions for improvement!
2222
- [YAGNI](#yagni)
2323
- [Do The Simplest Thing That Could Possibly Work](#do-the-simplest-thing-that-could-possibly-work)
2424
- [Separation of Concerns](#separation-of-concerns)
25-
- [Keep things DRY](#keep-things-dry)
2625
- [Code For The Maintainer](#code-for-the-maintainer)
2726
- [Avoid Premature Optimization](#avoid-premature-optimization)
28-
- [Boy-Scout Rule](#boy-scout-rule)
27+
- [Keep things DRY](#keep-things-dry)
28+
- [Boy Scout Rule](#boy-scout-rule)
2929

3030
### Relationships between modules, classes, components, entities
3131

@@ -141,51 +141,6 @@ Resources
141141

142142
- [Separation of Concerns (wikipedia.org)](https://en.wikipedia.org/wiki/Separation_of_concerns)
143143

144-
## Keep things DRY
145-
146-
**Don't Repeat Yourself**: Every piece of knowledge must have a single,
147-
unambiguous, authoritative representation within a system.
148-
149-
Each significant piece of functionality in a program should be implemented in
150-
just one place in the source code. Where similar functions are carried out by
151-
distinct pieces of code, it is generally beneficial to combine them into one by
152-
abstracting out the varying parts.
153-
154-
Why
155-
156-
- Duplication (inadvertent or purposeful duplication) can lead to maintenance
157-
nightmares, poor factoring, and logical contradictions.
158-
- A modification of any single element of a system does not require a change in
159-
other logically unrelated elements.
160-
- Additionally, elements that are logically related all change predictably and
161-
uniformly, and are thus kept in sync.
162-
163-
How
164-
165-
- Put business rules, long expressions, if statements, math formulas, metadata,
166-
etc. in only one place.
167-
- Identify the single, definitive source of every piece of knowledge used in
168-
your system, and then use that source to generate applicable instances of that
169-
knowledge (code, documentation, tests, etc).
170-
- Apply the
171-
[Rule of three](<https://en.wikipedia.org/wiki/Rule_of_three_(computer_programming)>).
172-
173-
Resources
174-
175-
- [Dont Repeat Yourself (wiki.c2.com)](http://wiki.c2.com/?DontRepeatYourself)
176-
- [Don't repeat yourself (wikipedia.org)](https://en.wikipedia.org/wiki/Don't_repeat_yourself)
177-
- [DRY Principle: Its Benefit and Cost with Examples (thevaluable.dev)](https://thevaluable.dev/dry-principle-cost-benefit-example/)
178-
179-
Related
180-
181-
- [Abstraction principle (wikipedia.org)](<https://en.wikipedia.org/wiki/Abstraction_principle_(computer_programming)>)
182-
- [Once And Only Once (wiki.c2.com)](http://wiki.c2.com/?OnceAndOnlyOnce) is a
183-
subset of DRY (also referred to as the goal of refactoring).
184-
- [Single Source of Truth (wikipedia.org)](https://en.wikipedia.org/wiki/Single_Source_of_Truth)
185-
- A violation of DRY is [WET](http://thedailywtf.com/articles/The-WET-Cart)
186-
(Write Everything Twice)
187-
- [Be careful with the code metric "duplicated lines" (rachelcarmena.github.io)](https://rachelcarmena.github.io/2018/02/27/duplication-you-are-welcome.html)
188-
189144
## Code For The Maintainer
190145

191146
Why
@@ -237,6 +192,51 @@ Resources
237192
- [Program optimization (wikipedia.org)](https://en.wikipedia.org/wiki/Program_optimization)
238193
- [Premature Optimization (wiki.c2.com)](http://wiki.c2.com/?PrematureOptimization)
239194

195+
## Keep things DRY
196+
197+
**Don't Repeat Yourself**: Every piece of knowledge must have a single,
198+
unambiguous, authoritative representation within a system.
199+
200+
Each significant piece of functionality in a program should be implemented in
201+
just one place in the source code. Where similar functions are carried out by
202+
distinct pieces of code, it is generally beneficial to combine them into one by
203+
abstracting out the varying parts.
204+
205+
Why
206+
207+
- Duplication (inadvertent or purposeful duplication) can lead to maintenance
208+
nightmares, poor factoring, and logical contradictions.
209+
- A modification of any single element of a system does not require a change in
210+
other logically unrelated elements.
211+
- Additionally, elements that are logically related all change predictably and
212+
uniformly, and are thus kept in sync.
213+
214+
How
215+
216+
- Put business rules, long expressions, if statements, math formulas, metadata,
217+
etc. in only one place.
218+
- Identify the single, definitive source of every piece of knowledge used in
219+
your system, and then use that source to generate applicable instances of that
220+
knowledge (code, documentation, tests, etc).
221+
- Apply the
222+
[Rule of three](<https://en.wikipedia.org/wiki/Rule_of_three_(computer_programming)>).
223+
224+
Resources
225+
226+
- [Dont Repeat Yourself (wiki.c2.com)](http://wiki.c2.com/?DontRepeatYourself)
227+
- [Don't repeat yourself (wikipedia.org)](https://en.wikipedia.org/wiki/Don't_repeat_yourself)
228+
- [DRY Principle: Its Benefit and Cost with Examples (thevaluable.dev)](https://thevaluable.dev/dry-principle-cost-benefit-example/)
229+
230+
Related
231+
232+
- [Abstraction principle (wikipedia.org)](<https://en.wikipedia.org/wiki/Abstraction_principle_(computer_programming)>)
233+
- [Once And Only Once (wiki.c2.com)](http://wiki.c2.com/?OnceAndOnlyOnce) is a
234+
subset of DRY (also referred to as the goal of refactoring).
235+
- [Single Source of Truth (wikipedia.org)](https://en.wikipedia.org/wiki/Single_Source_of_Truth)
236+
- A violation of DRY is [WET](http://thedailywtf.com/articles/The-WET-Cart)
237+
(Write Everything Twice)
238+
- [Be careful with the code metric "duplicated lines" (rachelcarmena.github.io)](https://rachelcarmena.github.io/2018/02/27/duplication-you-are-welcome.html)
239+
240240
## Boy Scout Rule
241241

242242
The Boy Scouts of America have a simple rule that we can apply to our

0 commit comments

Comments
 (0)