Class Diagrams
To learn class diagrams, you must know about the concepts of classes, advanced classes, relationships and advanced relationships.
Now, let’s start learning about class diagrams in UML:
Class diagrams are most commonly found diagrams while modeling software systems. A class diagram consists of classes, collaborations and interfaces. A class diagram is used to model the static design view of the system.
Contents [hide]
1 Common Properties
2 Contents
3 Common Modeling Techniques
3.1 Modeling Simple Collaborations
3.2 Modeling a Logical Database Schema
3.3 Forward and Reverse Engineering
The class diagram shares the common properties with the rest of the diagrams, a name and graphical elements that are a projection into the model. What distinguish the class diagram from the others are the contents of the diagram.
Class diagram contains the following:
Classes
Interfaces
Collaborations
Generalization, dependencies and associations
Like other diagrams, class diagrams may also contain notes and constraints. Class diagrams may also contain packages or subsystems which are used to organize the elements into groups. Generally, the class diagrams are used for:
Modeling the vocabulary of the system
Modeling the collaborations
Modeling the logical database schema
To model simple collaborations,
Identify the function or behavior of the part of a system you would like to model.
For each function or mechanism identify the classes, interfaces, collaborations and relationships between them.
Use scenarios (sequence of activities) to walk through these things. You may find new things or find that existing things are semantically wrong.
Populate the things found in the above steps. For example, take a class and fill its responsibilities. Now, convert these responsibilities into attributes and operations.
To model a schema,
Identify the classes whose state must be saved over the lifetime of the application.
Create a class diagram and mark these classes as persistent by using tagged values.
Provide the structural details for these classes like the attributes, associations with other classes and the multiplicity.
Minimize the common patterns which complicate the physical database design like cyclic associations, one-to-one associations and n-ary associations.
Provide the behavior for these classes by listing out the operations that are important for data access and integrity.
Wherever possible, use tools to convert the logical design to physical design.
To forward engineer a class diagram,
Identify the rules for mapping the models to the implementation language of your choice.
Depending on the semantics of the language, you may want to restrict the information in your UML models. For example, UML supports multiple inheritance. But some programming languages might not allow this.
Use tagged values to specify the target language.
Use tools to convert your models to code.
To reverse engineer the code,
Identify the rules for mapping the implementation language to a model.
Using a tool, navigate to the code that you want to reverse engineer. Use the tool to generate a new model.