The principle has been formulated by Andy Hunt and Dave Thomas in their book The Pragmatic Programmer. It is stated as "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system".
- Write code once, use it often.
- Change code in one place, see the change in all instances.
- Less code is good: It saves time and effort, is easy to maintain, and also reduces the chances of bugs.
- Writing/ Copying and pasting the same code or logic again and again.
- Divide your code and logic into smaller reusable units and use that code by calling it where you want.
- Put business rules, long expressions, if statements, math formulas, metadata, etc. in only one place.
If you like this article, don't forget to follow and stay in touch with my latest ones in the future by following me via:
- Twitter: https://twitter.com/RichardWynn01
- Medium: https://richard-wynn.medium.com
- Github: https://github.com/richard-wynn
Be interested? 😃 You can visit the links below read my other posts in my programming principles series