What is the Unified Modeling Language (UML) UML and the basic concepts of UML class diagrams

What is Unified Modeling Language UML (Unified Modeling Language)

UML

UML (Unified Modeling Language) is a general-purpose modeling language for describing the structure, behavior and interaction of software systems. It provides a set of notations and rules for creating visual graphical models that facilitate communication and understanding among developers, designers, and stakeholders.

Origin and History

  • UML originated in the early 1990s and was developed in collaboration with well-known software engineers such as James Rumbaugh, Grady Booch, and Ivar Jacobson.
  • These three engineers each had their own modeling methods (Rumbaugh's OOA, Booch's OOD, and Jacobson's OOSE), and in order to unify these methods and provide a common modeling language, they joined forces and developed UML.

Why use UML

  • Provide a unified standard: UML provides a unified standardized modeling language, so that different teams and personnel can use the same symbols and representations to communicate and exchange.
  • Visual expression: UML uses graphic symbols and diagrams to represent the structure and behavior of the system, so that complex concepts and relationships can be displayed in an intuitive way, improving understandability.
  • Easy to learn and use: The symbols and rules of UML are relatively simple, and there are a large number of tutorials and tool support, making it relatively easy to learn and use UML.
  • Support system design and analysis: UML provides a wealth of modeling tools and technologies to support the various stages of system design, analysis and implementation, helping developers better understand and plan the system.
  • Improve team collaboration: By using UML, team members can share and communicate the understanding and design of the system, promote collaboration and communication between teams, and reduce misunderstandings and mistakes.

Advantages of UML

  • Unified and standardized modeling language
  • Visually express complex concepts and relationships
  • easy to learn and use
  • Supports all phases of system design and analysis
  • Improve teamwork and communication

All in all, UML, as a general-purpose modeling language, provides standardized symbols and representations for software development, helps developers better understand, design and implement software systems, and improves the efficiency and quality of the software development process.

Purpose of Class Diagrams

UML class diagrams have the following main purposes:

  1. Shows the static structure of the classifiers in the system.
  2. Provides basic notation and notation for other structural diagrams specified by UML.
  3. Helpful for developers and team members.
  4. Business analysts can use class diagrams to model the system from a business perspective.

Components of a UML Class Diagram

A UML class diagram consists of the following two parts:

  1. A set of classes (Classes)
  2. Relationships between classes

What is a Class

Class is a description of a group of objects with similar roles in the system, including:

Structural features (Attributes)

Structural traits define what objects of the class "know" and include:

  • Represents the state of a class object
  • Describes the structural or static characteristics of a class

Behavioral characteristics (Operations)

Behavioral traits define what objects of a class "can do", including:

  • Defines possible interactions between objects
  • Describe the behavior or dynamic characteristics of a class

Class Notation

A class representation consists of three parts:

Class Name

Class names appear in the first division.

Class Attributes¶

Properties are displayed in the second section.
The attribute type is shown after the colon.
Properties correspond to member variables (data members) in code.

Class Operations (Methods)

Operations are shown in the third partition, which are the services provided by the class.
The return type of a method is shown after the colon at the end of the method signature.
The return type of a method parameter is shown after the colon following the parameter name.
Actions correspond to class methods in your code.

Class Relationships

relationship between classes

A class can have one or more relationships with other classes. Relationships can be one of the following types: (refer to the graphic on the right representing the relationship).

Relationship Type

type of relationship

Graphical Representation

graphic explanation

Inheritance (or Generalization):

Inheritance (or generalization):

  • Indicates an "is-a" relationship.
  • Abstract class names are shown in italics.
  • SubClass1 and SubClass2 are specializations of Super Class.
  • A solid arrow pointing from a child class to a parent class.
    inherit

Simple Association:

Simple association:

  • A structural link between two peer classes.
  • There is an association between Class1 and Class2.
  • A solid line connecting two classes.
    simple association

Aggregation:

polymerization:

  • A special type of association. Represents a "part-whole" relationship.
  • Class2 is part of Class1.
  • Class1 can be associated with multiple instances of Class2 (indicated by *).
  • The life cycles of Class1 and Class2 are independent.
  • A solid line with an unfilled diamond connected to an association endpoint of a composite class.
    polymerization

Composition:

combination:

  • A special aggregation relationship where when the whole is destroyed, the part is also destroyed.
  • The life cycle of Class2 is connected with Class1.
  • Class2 cannot exist independently.
  • A solid line with a filled diamond connected to an association endpoint of a composite class.
    combination

Dependency:

rely:
insert image description here

  • A dependency exists if a change to the definition of one class can cause a change to another class (but not vice versa).
  • Class1 depends on Class2.
  • Lines with dotted lines and open arrows.
    rely

Navigability

Navigability

Arrows indicate whether an instance of another class to which an instance is related can be determined when it participates in a relationship.

The illustration above shows that:

  • Given a spreadsheet, we can find all the cells it contains, but
  • We cannot determine from a cell which spreadsheet it belongs to, i.e. cannot navigate from cell to spreadsheet, so cell navigability is out of the question.
  • Given a cell, we can get the associated expression and value, but
    • Given a value (or expression), we cannot find the cell to which these properties belong, i.e. cannot navigate from a value or expression to a cell, so value or expression navigability is out of the question.

In short, navigability refers to whether an instance can be used to navigate to other instances related to it in a relationship. Based on the presence or absence of arrows, we can determine the feasibility of navigability.

Visibility of Class attributes and Operations

Visibility of class attributes and operations

In object-oriented design, there is a notation for the visibility of properties and operations. UML recognizes four visibility types: public (public), protected (protected), private (private) and package (package).

The visibility of attributes and operations is indicated using the +, -, #, and ~ symbols before the attribute and operation names in the class.

  • + indicates a public property or operation
  • - Indicates a private attribute or operation
  • # Indicates a protected attribute or operation
  • ~ Indicates the property or operation in the package

Reference: https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-class-diagram/

For learning use only, do not use for commercial and other illegal purposes

Guess you like

Origin blog.csdn.net/weixin_42727032/article/details/131722600