Class Diagrams

A lot of time has been spent focusing on analysis of the problem domain and drawing the diagrams necessary to represent the solutions. Sequence diagrams have been used to show the interactions between objects and classes. Activity diagrams have been used to model behavior of objects and classes. The final diagram that needs to be drawn is the actual class diagram. This diagram models all of the classes that will be used to build a system. One or more class diagrams may need to be built to sufficiently describe the system being built. A useful model is to build a primary or architecturally significant diagram and then one or more secondary diagrams. A class diagram models the classes and the class associations. The UML defines the following relationships that be can diagrammed: Association, Aggregation, Reflexive, Multiplicity, and Inheritence.

Continuing with the video example will illustrate a class diagram and possible relationships. Some of the classes that can be defined for this system would include a Video, Clerk, Customer, and VideoCatalog. To make things interesting and to illustrate generalization, we will define a superclass called Person that will generalize the behavior for both Customer and Clerk. A Person will be defined as having an account number and name information. This would allow both Customers and Clerks to rent videos. The VideoCatalog will aggregate or contain lots of Videos. A Video is associated with a Person so that tracking can be done. This relationship can be modeled with the following diagram.