First Aid Kit

 < Day Day Up > 



Ironically, the primary means of preventing a CAP Epidemic is not to use a particular tool: cut-and-paste. Nevertheless, there is more to it than that because if you still duplicate code and information without using cut-and-paste, you will be missing the point and creating extra work for yourself. You must therefore use tools that allow you to remove the need for duplicating information, particularly the need for programmers to perform the duplication manually.

You are likely to be using one of the primary tools for this purpose already, and that is the high-level language with which you are programming. The trick is to use the language to its full advantage, with the idea of removing duplication in mind. There are also language extensions, such as the aspect-oriented programming extension to Java named AspectJ, that provide additional methods for reducing duplication in ways that are not available in the standard language.

While the best method for preventing a CAP Epidemic is to avoid duplication entirely, it is not always possible due to limitations in the language or technology being used. This is where scripting languages such as Ruby, Python, Perl, and many others become important. Scripting languages allow fast implementation of useful utilities for automating information duplication tasks. Several of the common build utilities, such as Make and Ant, also have features that can assist in automating duplication.

If a CAP Epidemic has already reared its ugly head through your project’s code, it is time to refactor that code to remove the redundancies. To this end, refactoring tools such as Smalltalk’s refactoring browser and the refactoring options offered by IntelliJ’s IDEA for Java are excellent utilities to remove the tedious repetitive chores of refactoring. If you read Chapter 1, you will notice that refactoring tools were also mentioned there. Refactoring tools are important in curing many programmer illnesses, but are particularly useful for Premature Optimization and the CAP Epidemic due to their status as major illnesses and corresponding frequency of occurrence. Refactoring is an extremely useful process to begin with, and by removing the tedium and error-prone manual implementation, it becomes an essential part of a programmer’s repertoire.



 < Day Day Up > 



Preventative Programming Techniques. Avoid and Correct Common Mistakes
Preventative Programming Techniques: Avoid and Correct Common Mistakes (Charles River Media Programming)
ISBN: 1584502576
EAN: 2147483647
Year: 2002
Pages: 121
Authors: Brian Hawkins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net