Because Class Designer is coupled tightly with the underlying code, the available toolbox items depend to some extent on the language of the project to which you add a class diagram. Figure 5-1 presents the Class Designer toolbox for Visual Basic, which differs from the C# toolbox in only two respects:
There is an additional VB-specific type: the Module.
The Structure type is named Struct in the C# toolbox.
You may already have noticed our use of the word type, rather than prototype. Whereas the toolbox items of Application Designer and Logical Datacenter Designer are referred to as prototypes, those of Class Designer are referred to simply as types. We'll offer a brief description of each type in turn, and later we'll dig deeper into each one:
Class: This type provides a diagrammatic representation of a class in code, synchronized with the code so that code changes are reflected in the diagram and vice versa. The notation is similar to UML in that a class representation has compartments for members such as fields (attributes in UML) and methods (operations in UML), as well as domain-specific compartments for events and properties.
Enum: This type provides a diagrammatic representation of an enumeration in code.
Interface: The Interface type provides a diagrammatic representation of an interface in code. Inheritance relationships may be drawn between classes and interfaces, rendering the interfaces as lollipop shapes attached to the classes that implement them.
Abstract Class: This type represents an abstract (MustInherit) class in code. The abstract class may provide concrete implementations of some methods, with other methods left to be implemented in derived concrete classes. An abstract class is rendered on the design surface with a broken-line boundary to distinguish it from a concrete class.
Structure (Struct in C#): The Struct type provides a diagrammatic representation of a struct (value type) in code, with compartments to show fields, methods, and so on.
Delegate: The Delegate type provides a diagrammatic representation of a delegate method, with the delegate parameters shown as members.
Module (Visual Basic only): This type represents a Visual Basic module and is not available in the Visual C# Class Designer.
Inheritance: The inheritance toolbox item represents a relationship, or connection, between types, rather than a type itself. The relationship connects a derived type to a base type (a subclass to a superclass) and is equivalent to the UML generalization relationship.
Association: This toolbox item also represents a relationship — between a class and the type of one of its members. Unlike most UML tools, the Visual Studio Class Designer allows any member to be shown within a type, or as an association to another type, completely interchangeably according to your preference. Unlike UML, the stronger forms of association — aggregation and composition — are not distinguished on diagrams because they are not distinguishable in code.
Comment: As in previous chapters, a Comment is just a free text note that adds clarity to your diagrams. Unfortunately, it is not possible to attach comments to other elements on class diagrams.