Class Diagrams


The class diagram in Figure 13-2 shows the major classes and relationships in the program. A treeMap class has public methods named Add and Get and holds a reference to a treeMapNode in a variable named topNode. Each treeMapNode holds a reference to two other treeMapNode instances in some kind of container named nodes. Each treeMapNode instance holds references to two other instances in variables named key and value. The key variable holds a reference to some instance that implements the IComparable interface. The value variable simply holds a reference to some object.

Figure 13-2. Class diagram of treeMap


We'll go over the nuances of class diagrams in Chapter 19. For now, you need to know only a few things.

  • Rectangles represent classes, and arrows represent relationships.

  • In this diagram, all the relationships are associations. Associations are simple data relationships in which one object holds a reference to, and invokes methods on, the other.

  • The name on an association maps to the name of the variable that holds the reference.

  • A number next to an arrowhead typically shows the number of instances held by the relationship. If that number is greater than 1, some kind of container, usually an array, is implied.

  • Class icons can have more than one compartment. The top compartment always holds the name of the class. The other compartments describe functions and variables.

  • The «interface» notation means that IComparable is an interface.

  • Most of the notations shown are optional.

Look carefully at this diagram and relate it to the code in Listing 13-1. Note how the association relationships correspond to instance variables. For example, the association from treeMap to TReeMapNode is named topNode and corresponds to the topNode variable within treeMap.




Agile Principles, Patterns, and Practices in C#
Agile Principles, Patterns, and Practices in C#
ISBN: 0131857258
EAN: 2147483647
Year: 2006
Pages: 272

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net