From Wikipedia, the free encyclopedia Don’t repeat yourself
Don’t repeat yourself
DRY)
In software engineering, Don’t Repeat Yourself (DRY is Kent Beck has mentioned that he does not "subscribe
a principle of software development aimed at reducing to [DRY] for test code because [he] want[s] [his] tests to
repetition of information of all kinds, especially useful in read like a story".[2]
multi-tier architectures. The DRY principle is stated as
"Every piece of knowledge must have a single, unambigu-
ous, authoritative representation within a system." The
See also
principle has been formulated by Andy Hunt and Dave • Abstraction principle (programming)
Thomas in their book The Pragmatic Programmer. They ap- • Code reuse
ply it quite broadly to include "database schemas, test • Single Source of Truth
plans, the build system, even documentation."[1] When • Occam’s Razor
the DRY principle is applied successfully, a modification • Separation of concerns
of any single element of a system does not require a • KISS principle
change in other logically-unrelated elements. Addition- • You Ain’t Gonna Need It
ally, elements that are logically related all change pre- • Rule of three (programming)
dictably and uniformly, and are thus kept in sync. Besides • Redundancy (engineering)
using methods and subroutines in their code, Thomas • Mirror (computing)
and Hunt rely on code generators, automatic build sys-
tems, and scripting languages to observe the DRY princi-
ple across layers.
References
[1] Dave Thomas, interviewed by Bill Venners
(2003-10-10). "Orthogonality and the DRY
Applying DRY Principle". http://www.artima.com/intv/dry.html.
Also known as Single Source of Truth, this philosophy is Retrieved 2006-12-01.
prevalent in model-driven architectures, in which soft- [2] Kent Beck, interviewed by Martin Lippert
ware artifacts are derived from a central object model ex- (2010-09). "Software Engineering Radio Episode
pressed in a form such as UML. DRY code is created by da- 167: The History of JUnit and the Future of Testing
ta transformation and code generators, which allows the with Kent Beck". http://www.se-radio.net/2010/
software developer to avoid copy and paste operations. 09/episode-167-the-history-of-junit-and-the-
DRY code usually makes large software systems easier to future-of-testing-with-kent-beck. Retrieved
maintain, as long as the data transformations are easy 2011-01-25.
to create and maintain. Tools such as XDoclet and XSLT
are examples of DRY coding techniques. Examples of sys-
tems that require duplicate information are Enterprise
External links
Java Beans version 2, which requires duplication not just • Orthogonality and the DRY Principle
in Java code but also in configuration files. Examples of • Don’t Repeat Yourself at WikiWikiWeb
systems that attempt to reduce duplicate information in- • Once and Only Once at WikiWikiWeb
clude the Symfony, web2py and Django web frameworks, • 97 Things Every Programmer Should Know (O’Reilly)
Ruby on Rails application development environment and • Codereflect.com - DRY Principle
Enterprise Java Beans version 3.
Retrieved from "http://en.wikipedia.org/w/index.php?title=Don%27t_repeat_yourself&oldid=461783572"
Categories:
• Software development philosophies
• Programming principles
This page was last modified on 21 November 2011 at 16:10. Text is available under the Creative Commons Attribution-
ShareAlike License; additional terms may apply. See Terms of use for details. Wikipedia® is a registered trademark of
the Wikimedia Foundation, Inc., a non-profit organization.Contact us
Privacy policy About Wikipedia Disclaimers Mobile view
1