18.5. Other Examples of Table Lookups

 < Free Open Study > 

A few other examples of table lookups appear in other sections of the book. They're used in the course of discussing other techniques, and the contexts don't emphasize the table lookups per se. Here's where you'll find them:

  • Looking up rates in an insurance table: Section 16.3, "Creating Loops Easily From the Inside Out"

  • Using decision tables to replace complicated logic: "Use decision tables to replace complicated conditions" in Section 19.1.

  • Cost of memory paging during a table lookup: Section 25.3, "Kinds of Fat and Molasses"

  • Combinations of boolean values (A or B or C): "Substitute Table Lookups for Complicated Expressions" in Section 26.1

  • Precomputing values in a loan repayment table: Section 26.4, "Expressions."

cc2e.com/1872

Checklist: Table-Driven Methods

  • Have you considered table-driven methods as an alternative to complicated logic?

  • Have you considered table-driven methods as an alternative to complicated inheritance structures?

  • Have you considered storing the table's data externally and reading it at run time so that the data can be modified without changing code?

  • If the table cannot be accessed directly via a straightforward array index (as in the age example), have you put the access-key calculation into a routine rather than duplicating the index calculation in the code?


 < Free Open Study > 


Code Complete
Code Complete: A Practical Handbook of Software Construction, Second Edition
ISBN: 0735619670
EAN: 2147483647
Year: 2003
Pages: 334

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