diff options
author | Julio Lozovei <jlozovei@gmail.com> | 2019-05-20 10:15:43 -0300 |
---|---|---|
committer | Julio Lozovei <jlozovei@gmail.com> | 2019-05-20 10:15:43 -0300 |
commit | d2f4ad77f87479e8fe137319d79c19e87c725c9a (patch) | |
tree | b05b00416e792ddc26771d55594e5f176acfd8c1 | |
parent | a42732db8525f7cb324dc6257f8d2bbdea8024e6 (diff) |
remove code sample + shorten text
- remove code sample
- reduce text size
- add `See also` section
-rw-r--r-- | README.md | 21 |
1 files changed, 4 insertions, 17 deletions
@@ -388,28 +388,15 @@ See also: > Every piece of knowledge must have a single, unambiguous, authoritative representation within a system. -DRY is an acronym for _Don't Repeat Yourself_. This principle aims to help developers reducing the repetition of code and keep the information in a single place. +DRY is an acronym for _Don't Repeat Yourself_. This principle aims to help developers reducing the repetition of code and keep the information in a single place and was cited in 1999 by Andrew Hunt and Dave Thomas in the book [The Pragmatic Developer](https://en.wikipedia.org/wiki/The_Pragmatic_Programmer) > The opposite of DRY would be _WET_ (Write Everything Twice or We Enjoy Typing). -The principle is easy to understand and can be used with any other methodology, design pattern and/or language. It was cited in 1999 by Andrew Hunt and Dave Thomas in the book [The Pragmatic Developer](https://en.wikipedia.org/wiki/The_Pragmatic_Programmer). +In practice, if you have the same piece of information in two (or more) different places, you can use DRY to merge them into a single one and reuse it wherever you want/need. -In practice, if you have the same piece of code/information in two (or more) different places, you can use the DRY Principle to merge those pieces into a single one and reuse it wherever you want/need. The DRY principle can be used for codes, documentations, schemas, build systems... - -Besides avoiding the repetition, DRY help developers to deliver maintainable, readable and reusable code. It also helps developers to keep the testing step easier - in this specific case, DRY keep unit and integration tests simple. Because if the code isn't repeated, you just need to test it a single time. - -In a real-world application, we can translate the use of DRY with this code: - -```js -// check if user is logged in -function isUserLoggedIn() { - const user = context.getUser(); - - return typeof user.id !== null; -} -``` +See also: -In the example above, to check if the user is logged in we can import this function to anywhere and get the result - without DRY, you would write it every time you need to know if the user is logged in. +- [The Pragmatic Developer](https://en.wikipedia.org/wiki/The_Pragmatic_Programmer) ## TODO |