- Elements of a class diagram
A class diagram describes the structure of a system via classes and the relationships among them.
Class diagrams are the most common diagrams in object-oriented systems modeling.
For example, a diagram can represent a stock management system.
Elements of a class diagram
A class diagram includes the following elements:
- Class: represents the application structures. Each class is divided into four compartments:
For example, the Inventory class contains the ProductList attribute. This class also groups the AddProduct and DeleteProduct operations. These operations can be applied to the class instances.
- the name of the class indicates what the class is, not what it does.
- the attributes of the class determine the class characteristics.
- the operations of the class represent the possible actions on the class.
- the properties of the class. A property is a specific type of attribute whose value can be read or written using the getter and setter functions, respectively. Using a function allows you to perform complex operations when reading or writing a characteristic. For example, a class used to model an order form could have a "TotalValue" property accessible in read-only mode. In this case, the getter does not exist and the setter iterates over the list of elements of the order and calculates the value when the function is called, rather than storing the value in an attribute.
Remark: UML provides three visibility levels for attributes and operations:
- Public: the element is visible to all other classes.
- Protected: the element is visible to the class and its subclasses.
- Private: the element is visible to the class only.
- Relationship: describes how classes interact with each other. There are three types of relationships:
- Association: Structural relationship between classes. For example, the Orders class is linked to the Product and Customer classes. A Customer can place several Orders. An order contains several products. An order must contain at least one product.
- Dependency: Use relationship that establishes that the instances of a class are linked to the instances of another element. For example, the Orders class uses the Inventory class: before adding a product to an order, you must make sure the product is available in stock.
- Generalization: Relationship between a general class (parent) and a specific class (child) that derives from it. For example, the Sail Boat class and Speed Boat class are derived from the Boat class.
- Packages: divides and organizes the diagram representation (in the same way that directories organize files). Each package can contain classes and relationships.
The generation of a class diagram allows you to create the structure of the WINDEV, WEBDEV and WINDEV Mobile classes used in your application.
This page is also available for…