DRY code
From Wikipedia, the free encyclopedia
| This article is orphaned as few or no other articles link to it. Please help introduce links in articles on related topics. (July 2006) |
| It has been suggested that this article or section be merged into Don't repeat yourself. (Discuss) |
In software engineering and computer science DRY code is a design pattern that does not duplicate metadata. DRY is an acronym for Don't Repeat Yourself.
The DRY code philosophy is stated as Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
This philosophy is also prevalent in model-driven architectures where software artifacts are derived from a central object model expressed in some form such as UML.
DRY code is created by data transformation which allows the software developer to avoid copy and paste operations. DRY code usually makes large software systems easier to maintain as long as the data transformation are easy to create and maintain. Tools such as XDoclet and XSLT are examples of DRY coding techniques.
Examples of systems that require duplicate information are Enterprise Java Beans. EJBs require duplication not just in Java code but also in configuration files.
Examples of systems that attempt to reduce duplicate information include the Ruby on Rails application development environment.
[edit] Teaching DRY coding skills
Unfortunately data transformation skills are not taught in most junior-level software engineering courses. Current computer science curricula tend to be heavily weighted toward procedural skills such as Java, C++ or C#.
The use of DRY code becomes increasingly important as developers create applications that use multi-tier architectures. The Model-view-controller architectural pattern also challenges software developers to use data transformations.
Recent developments in some language features such as Java annotations may allow additional metadata to be stored within object class definitions and accessed at run time allowing features such as automatic view generation directly from models.
[edit] See also
[edit] References
- Orthogonality and the DRY Principle A Conversation with Andy Hunt and Dave Thomas by Bill Venners March 10, 2003
- Java Generics: Don't Repeat Yourself
- Keep it DRY, SHY and tell the Other Guy by Andy Hunt and Dave Thomas from the Pragmatic Programmers.

