Summary

 < Day Day Up > 



The symptoms of Hardcode are:

  • Numbers and strings that are embedded directly in the code.

  • Numbers and strings that are cut-and-pasted to multiple locations in the code.

  • Localization requires changes in the code and in multiple locations.

To prevent Hardcode:

  • Standardize location and access methods for number, strings, and any other configurable data.

  • Prefer XML if it is appropriate because of the wide range of tools available.

  • Standardize asset creation, locations, and management.

To cure the effects of Hardcode:

  • Refactor localized strings and porting values first.

  • Refactor commonly changed values to a data source outside the code.

  • Use context highlighting available on most modern editors to assist in spotting hardcoded string and numbers.

  • Collect any repeated values in a single location in the code.

  • Move most of these values to a source outside the code, leaving only those determined to be performance critical in the code.



 < 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