Wednesday, February 16, 2011

Code Complete by Steve McConnell : Chapter 6

A module is a collection of data and the routines that act on the data. The author provides empirical evidence to prove that modularity contributes more to maintainability than structure does and is the most important factor in preventing corrective maintenance. Modular programming also improves maintainability and comprehension by programmers.

The author emphasizes on loose coupling of modules and strong cohesion among routines belonging to a single module.

The author then enlists the benefits of Information hiding such as:

  1. Hide module level secrets: These include
    • Data Structures
    • Algorithms
    • Areas that can change
      • Hardware interaction
      • Data size
      • Input and Output
      • Nonstandard language features
  2. Ease of Modification: Changes are localized to routines of module when information is hidden from the rest of the program.
  3. Better Readability:
  4. Increased Reliability:
The author then enlists barriers that prevent usage of information hiding:
  1. Excessive distribution of Information: If implementation of employee records as an array of 1000 elements is known to every part of the program, it deters use of information hiding.
  2. Circular Dependencies among modules: If more than one modules are using the same set of data, the data would not be kept hidden from the rest of the modules.
  3. Perceived performance penalties: The belief that information hiding will result into degrade in performance deters the use of information hiding.
The author then enlists some of the areas of a program around which modules can be created:
  1. User Interface
  2. Hardware Dependencies
  3. System Dependencies
  4. Data Management
  5. Real world objects and abstract data types
  6. Related Operations
  7. Reusable Code
The author concludes the chapter showing the ways modules can be implemented in different programming languages.

No comments:

Post a Comment