CSC/ECE 517 Summer 2008/wiki2 5 mo: Difference between revisions
Maryorazem (talk | contribs) |
Maryorazem (talk | contribs) |
||
Line 7: | Line 7: | ||
This is a very strong requirement. It includes duplication at the | This is a very strong requirement. It includes duplication at the | ||
highest levels of program requirements and design. | highest levels of program requirements and design. | ||
== One Authoritative, Unambiguous Representation == | |||
What does this really mean? At the highest level, the system architecture | What does this really mean? At the highest level, the system architecture |
Revision as of 20:40, 26 June 2008
The DRY Principle
'Don't Repeat Yourself', DRY, is a software engineering principle that encourages the reduction of duplication in software. According to Dave Thomas, the pragmatic programmer, "DRY says that every piece of system knowledge should have one authoritative, unambiguous representation". [1] This is a very strong requirement. It includes duplication at the highest levels of program requirements and design.
One Authoritative, Unambiguous Representation
What does this really mean? At the highest level, the system architecture needs to have global definitions areas for functions that cross different functional design boundaries. A classic example of a system breakdown due to duplication in system requirements, is that of the Mars Climate Orbiter [2]. The space vehicle malfunctioned do to a system architecture failure. Two different parts of the system were working with two different measurement systems, one in metric units and the other in imperial units. Something as important as system measurements should have been abstracted out to a system wide area in the architecture of the software. It should have been specified in only one area of the system requirements, but it obviously was specified in both parts of the system.
At intermediate levels, if different objects need very similar functions, the code should not be duplicated in in class. One option is to have the two classes inherit from a parent that has the function coded there. This is not always an available option because many OO languages do not support multiple inheritance. With Java, you have interfaces, but they don't really help that much. You still need to code the method in more than one place.