CS 477 Lecture Notes

Week Four, Tuesday: Introduction to Objects

What is a Module?

A named, bounded, contiguous sequence of statements.

You want to divide a programming project into modules before you start writing any code. How do you divide up the project?

Cohesion

Modules (should) have cohesion. Coincidental cohesion: The Wonder Software Company motto is: "If any of our modules have cohesion, it's a wonder." That's coincidental cohesion. Purely coincidence. The various types of cohesion include:

  1. Informational (actions on same data; an object class, for example)
  2. Functional (does just one thing; a class method, for example)
  3. Communicational (same as procedural, but the actions are on a single set of data)
  4. Procedureal (main() in a batch mode program, for example)
  5. Temporal (init() and start() in applets, for example)
  6. Logical (related actions; a math library, for example)

Coupling

  1. Content (a module refers to the contents of another)
  2. Common (access to common data; global variables, for example)
  3. Control (action of calling module is influenced by called module result)
  4. Stamp (passing unneeded data in a large structure, for example)
  5. Data (desirable; all arguments are needed by the called module)

Data Encapsulation

Definition: the gathering together into one unit of all aspects of the real-world entity modeled by that unit. Data encapsulation is abstraction. The developer can conceptualize at a higher level. This leads to stepwise refinement.

Abstract Data Types

Abstract data types implement data encapsulation.

Information Hiding

Data and procedureal abstraction are instances of information hiding, which hides the details of implementation.

Objects

Inheritance: classes and subclasses. Inheritance provides another layer of data abstraction.

Polymorphism and Dynamic Binding

A powerful development technique, polymorphism can complicate debugging. It can make understanding the product difficult for the maintainer.

Cohesion and Coupling of Objects

It's desirable to have objects with high cohesion and low coupling.

Reuse

Accidental reuse, deliberate (designed for) reuse.

Reuse Case Studies

Raytheon Missile Systems Division, Toshiba Software Factory, and NASA Software.

Reuse and Maintenance

Reuse is of greater benefit to maintenance than to development. Modules designed for reuse are thoroughly documented and tested.

Objects and Productivity

Managing the development is easier. Maintenance costs are lower. Problems with inheritance: don't overuse.


This page established January 24, 1998; last updated February 9, 1999.