In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what are the basic knowledge points of UML class diagrams?" in the operation of actual cases, many people will encounter such a dilemma, and then let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Class: the abstraction of things in the real world. Name, property, and method.
When UML describes a class, the degree of openness is expressed as "-, +, #".
"-" is private, "+" is public, and "#" is protection.
Second, the relationship between classes.
1. Association:
(1) General association: one-way association; two-way association; there can be multiple associations between two classes; a class can be associated with multiple classes; association classes. Self-related. When the method is called, an association is generated.
Relationship between whole and part:
(2) aggregation: loose coupling. Hollow diamond. Examples: books and shelves.
(3) combination: tight coupling. Solid diamond. Example: people and arm, people before arm;book and page, book before page
The difference between aggregation and composition in the UML class diagram:
Aggregation, as the name implies, gathered together, there are no strong life constraints; combined, assembled, life constraints are very strong.
It is easy to understand with examples:
Geese and wild geese are aggregated. A wild goose belongs to a flock of geese, and a flock of geese can have many geese. Geese leave the flock of geese or geese, geese leave this goose, and other geese. Geese can exist independently from the geese. The relationship between birds and wings is a combination. There is no bird without wings, only wings can not become birds, wings without birds is meaningless, birds without wings can not constitute birds. Wings cannot exist independently of birds.
That is, the dependence between the whole and the part is different.
The connection between two objects can have its own properties and behavior.
Apply to the associated modifier.
1) name (association): describe the nature of the relationship with one
2) role: the responsibility of a class near one end of an association to a class at the other end of the association.
3) Multiplicity: the multiplicity of associated roles indicates how many interconnected objects there are in an associated instance. 1, 1, 5, 5, 5, 5, 5.
2. Dependence
Dependency is a usage relationship in the UML class diagram. Indicate that a change in the specification of one thing may affect another thing that uses it. But not necessarily vice versa. It can be used between two classes, between two packages, or between two artifacts.
Structured relationships include dependencies. If you have a structured relationship, you should use association.
Class a depends on class b, so use the arrow to point to class a, and the arrow cannot be reversed.
3. Generalization
Is-a-kind-of, inheritance.
In C++, use ":", the key words public or private
In Java, the keyword extents is used, there is no public or private.
Single inheritance: a subclass cannot have two or more parent classes.
Multiple inheritance: a class has two or more parent classes.
4. Realize
Is the semantic relationship between class elements, in which one class element describes the contract guaranteed by the other class element.
The implementation relationship between class and interface.
Third, the composition of UML class diagram:
Used to describe the static part of the system
The composition of class diagram
-- classes
-- Interfaces
-- Collaborations
-- Dependency,Generalization,and
After the class is abstracted, the relationship between the classes is determined. Polymerization relationship, using a hollow diamond, the direction of the diamond can not be drawn upside down.
A method should be placed in the executor's class, not in the caller
The UML class diagram is discussed in depth:
1. Visibility (visibility)
Public 、 private 、 protected
2. Scope: each instance has its own properties and methods.
Static member: share a member for all instances of a class. Underscores are used in UML. This member can be called directly through the class name.
3. Attributes. Freeze attributes: equivalent to const in C++, that is, defining constants.
4. Abstract classes: cannot be instantiated. Described in UML: class name italics. The interface is implemented through concrete class inheritance.
5. Multiplicity
Example: company
After the class is abstracted from the noun, determine the properties and methods of the class. Determine the method: a collection of operations. Class-to-class relationships: all four relationships should be accurately described. We also need to modify the relationship.
This is the end of the content of "what are the basic knowledge points of UML class diagram". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.