Saturday, May 14, 2011

Code Complete by Steve McConnell : Chapter 12

The author discusses tips to use user-defined data types. The authors suggest to use structured data to simplify operations on blocks of data and clarify data relationships. Structured data simplify parameter passing and reduce maintenance.

The authors then discuss the benefits of using table look-ups instead of complicated conditional statements. The authors discuss three techniques to look up an entry in the table:
  • Direct Access - The author discusses two ways, directly using data as a key to table and the other is fudging the table-lookup keys.
  • Indexed Access - This works similar to handling of virtual memory address to physical memory address in operating systems.
  • Stair-step Access - The entries in a table are valid for ranges of data. The authors also provide some suggestions on using the technique effectively.
The authors then discuss the advantages of using abstract data types (ADTs) such as:
  • Hide implementation details
  • It's easier to improve performance
  • Changes are localized
  • The program becomes self-documenting
The authors then give some examples of ADTs for real world entities and also some guidelines of designing ADTs.

No comments:

Post a Comment