Thursday, July 09, 2009

The DRY Principle

The DRY Principle…
http://en.wikipedia.org/wiki/Don't_repeat_yourself
Quote from discussions:
There is no reason that one would "impose standards based on DRY compliance."
DRY is a general principle, not a law that is usually codified and strictly enforced.
Aka “Single Point of Truth”; “Single Point of Maintenance”


Quote on Refactoring:
Rule of three is a code refactoring rule of thumb to decide when a replicated piece of code should be replaced by a new procedure. It states that you are allowed to copy and paste the code once, but that when the same code is replicated three times, it should be extracted into a new procedure. The rule was introduced by Martin Fowler in Refactoring[1] and attributed to Don Roberts.

Duplication in programming is a bad practice because it makes the code harder to maintain. When the rule encoded in a replicated piece of code changes, whoever maintains the code will have to change it in all places correctly. This process is error-prone and often leads to problems. If the code exists in only one place, then it can be easily changed there.


While refactoring application systems that are primarily VB6 and VB.NET 1.1 code written under the VB .NET 2.0 and 3.5 Frameworks to utilize the most efficient tools provided by these newer Frameworks, I find the greatest gains in manageability, efficiency, memory footprint, overall application size, and comprehensive extraction of business rules still comes from enforcing good practices based on fundamental principals.

Utilizing VS Code Analysis (2005 & 2008) and Code Metrics 2008 are good assistants even after the basics are covered, but one rudimentary fact remains unchanged - if you cannot get a team wide buy-in on practices (not just principles), you are wasting time and energy.

No comments: