UML class Diagram

Source: Internet
Author: User

Class diagram

The class diagram shows the construction module of the object-oriented system. Depicts a static view of a model or part of a model, showing the properties and behaviors it contains, rather than describing the function or refinement of the operation in detail. Class diagrams are most commonly used to express relationships between multiple classes and interfaces. Generalization (generalizations), aggregation (aggregations), and association (associations) are the expressions of inheritance, composition, or application, and connection between classes, respectively.

??

The following figure shows the aggregation relationship between classes. Weak aggregation (light arrow) is represented in the class "account" using "AddressBook", but it is not necessary to include an instance of it. Strong aggregation (The black arrow in the diagram) indicates that the target class contains the source class, for example, "contact" and "Contactgroup" values are included in "AddressBook".

Class (Classes)

A class is an element that defines the properties and behaviors that an object has. Behavior is described by the appropriate message that the class can understand and the action that is appropriate for each message. Classes may also define constraints, tag values, stereotypes.

Class of the column (class Notation)

The class is represented by a rectangle. In addition to the name of the class, you can optionally display properties and actions. Columns are used to display the name, properties, and operation of the class, respectively.

??

In the following illustration, the class name of the class is displayed in the topmost column, and the columns below it show detailed properties, such as: the "Center" property displays the initialized value. The last side of the column shows operations such as Setwidth,setlength and setposition and their arguments. The label before the property and operation name indicates the visibility of the property or operation: if the "+" sign is used, the property or operation is public; The "-" sign indicates that the attribute or operation is private. The "#" number is that this attribute or operation is defined as protected, and the "~" sign represents the visibility of the package.

Interface (Interfaces)

An interface is a behavior specification that implementers agree to meet, and is a convention. To implement an interface, a class must support the behavior of its requirements, allowing the system to handle unrelated elements in the same way, the common interface.

The interface has a shape style similar to the class, which contains the specified operation, as shown in. You can also draw a circle if you don't have a clear, detailed operation. When a circle is drawn, there is no target arrow for the connection to this ring-shaped column.

Table (Tables)

Tables, although not part of the basic UML, are still examples of "graphs" that can be completed. In the upper right corner, draw a small icon of a table to represent it. Table properties are represented by a "graph"? column. Most forms have a primary key, which is a unique loadline combination of one or several fields and a primary key operation to access the table, and the primary key operation "graph" is? Pk?. Some tables have one or more foreign keys, using one or more fields plus a foreign key operation, mapped to the primary key of the related table, the foreign key operation "Figure" is? Fk?.

Association (associations)

Correlation indicates that there is a relationship between two model elements, which is typically implemented as an instance variable in a class. A connector can contain named roles, cardinality, direction, and constraints on both ends. An association is an ordinary relationship between elements. If there are more than two elements, you can also use a diamond association relationship. When generating code from a class diagram, the object at the end of the association becomes the instance variable in the target class. See example "Playsfor" becomes an instance variable in the "Player" class.

Generalization (generalizations)

Generalization is used to illustrate inheritance relationships. Connections are from a specific class element to a generic class element. The meaning of generalization is that the source class inherits the attributes of the target class. The graph shows a subclass of a parent class generalization, and an instance of the class "Circle" will have the attribute "X_position", "y_position", "radius" and the method "display ()". Note: The class "Shape" is abstract and the class name is displayed in italics.

A view with the same information is displayed.

Aggregation (aggregations)

Aggregations are often used to describe elements that are composed of smaller components. The aggregation relationship is represented as a white diamond arrow pointing to the target class or parent class.

??

Stronger form of aggregation-combined aggregation (strong aggregation)-is shown as a black Diamond arrow, which is used to combine each of the containing components that are maximized. If the parent of a combined aggregate is deleted, all parts associated with him are usually deleted, but if a part is removed from the assembly, the entire composition will not be deleted. A combination is a transitive, asymmetric relationship and recursion.

??

The following illustration shows the difference between weak and strong aggregations. "Address Book" consists of many "contacts" and "Contact groups". "Contact Group" is a virtual grouping of "contacts"; "Contact" can be included in more than one "contact group". If you delete an "address book", All "contacts" and "contact groups" will also be deleted, and if you delete "Contact Group", no "contacts" will be deleted.

Association Class (Association Classes)

An association class is a construct that allows associated connections to have properties and operations. The following example shows a connection that is much more than simply connecting two classes, such as assigning an item to "employee". The role of "employee" in a project is a complex entity that has both its own and the details that are not part of the "employee" or "project" classes. For example, "employee" can work on several projects at the same time, with different job titles and corresponding security permissions.

Dependency (Dependencies)

Dependencies are used to describe a wide range of dependencies between model elements. There is usually a relationship between two elements in the early stages of the design process, because it is early and uncertain what the relationship is, and at the end of the design process the inheritance is grouped into an existing stereotype (stereotypes can be instantiated? Instantiate?, Trace? Trace?, import? and other relationships), or be replaced with a more explicit type of connector.

Tracking (Traces)

Tracking relationships are a special kind of dependency. A set of model elements that connect model elements or cross-model but have the same concept. Tracking is often used to track changes in requirements and models. Because the changes are bidirectional, the order of this dependency is usually ignored. The properties of this relationship can be specified as one-way mappings, but the trace is bidirectional, informal, and rarely computable.

Implementation (realizations)

is the execution or implementation of the source object, the implementation is used to express the traceability and integrity of the model-the business model or requirement is implemented by one or more use cases, the use case is implemented by the class, the class is implemented by the component, and so on. This implementation runs through the mapping requirements and classes of the system design until the abstract modeling level. Thus ensuring a grand vision of the entire system, it also reflects all the tiny components of the system, as well as the details of constraining and defining it. The implementation relationship is represented by a solid arrow with a dashed line.

Nesting (nestings)

A nested connector is used to indicate that the source element is nested within the target element. Displays the definition of "inner class", although in the EA, it is shown more in terms of where they are in the project hierarchy view.

UML class Diagram

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.