Copyright © 2012 David Schmidt

Lecture 4:
Class diagrams




An object diagram is a "blueprint" of how storage is managed when a system executes. It is similar to the "traffic diagram" an architect makes of a building that shows the movement of people through the building while the building is used.

But an architect also makes a "floor plan" of the building, which shows the layout of rooms, halls, and stairs that will be constructed for use.

A class diagram is a blueprint of the components needed to build an executing software system --- it is the "floor plan" of the software system.

UML class notation is used to draw a class diagram. We use the variant that is documented in the Visual Studio lecture notes. There is a related tool, Nclass, which helps you draw class diagrams and generate Visual Studio projects from them. Nclass was used to make the diagram below. (There are more in the VS Notes.)

Example

Say we are designing a computer simulation of students taking an exam. The students bring some blank paper, and some pencils and pens. At the exam, each student gets a question sheet; all the students share (well, look at) the big clock at the front of the room.

The computer simulation must construct objects for the entities just described; here is an object diagram of what the exam simulation might look like while it is executing:

The object diagram gives big clues about what classes must be written for the simulation. Here is a class diagram that could generate the above object diagram:

The meanings of boxes and arrows are documented in the Visual Studio lecture notes. Here is a quick summary:

There is a tool, Nclass, which helps you draw class diagrams and generate Visual Studio projects from them.

Exercise