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/02 Report--
This article will explain in detail about the characteristics of UML dependency and points for attention. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
Characteristics of UML dependencies
For two relatively independent systems, when one system is responsible for constructing an instance of another system, or relying on the services of another system, the relationship between the two systems is mainly reflected in dependencies, such as machines and parts that produce parts. the machine is responsible for constructing the part object. Another example is the rechargeable battery and the charger, which is charged through the charger. Another example is the bicycle Bicycle and the pump Pump, which is inflated by a pump. Figure 1-39 shows the class block diagram of the Bicycle class and the Pump class.
Figure 1-dependency between the 39Bicycle class and the Pump class
There is a UML dependency between the Bicycle class and the Pump class, and there is no need to define variables of type Pump in the Bicycle class. The Bicycle class is defined as follows:
PublicclassBicycle {
/ * inflate the tires * /
Publicvoidexpand (Pumppump) {
Pump.blow ()
}
}
In today's life, it is not usual to equip a bicycle with a special pump, but to borrow a pump from a nearby garage when it needs to be inflated. In the program code, the expand () method of the Bicycle class has a parameter of type Pump. The following program code indicates that a bicycle has been inflated in two repair sheds:
MyBicycle.expand (pumpFromRepairShed1); / / go to * garage to inflate
MyBicycle.expand (pumpFromRepairShed2); / / several days later, inflate in the second garage.
Considerations for the use of UML dependencies
1. When code is generated for two classes that have a dependency, no attributes are added to the class of the relationship. But generate specific statements that are required to support the relationship. In C++, the necessary # include statements are included in the generated code.
For example, class A depends on class B, and class A has no B attribute, so you need to find B in other ways. There are three ways:
If B is global, class A knows it exists.
If B is instantiated as a local variable in a class An operation, class A knows it exists.
If B is passed as an argument to class A, class A knows it exists.
One of these three methods must be used in dependency relationships.
The second difference between associations and UML dependencies is direction. Associations can be bi-directional, while dependencies can only be unidirectional.
two。 There are also dependencies between packages. For example, package A depends on package B. Package A cannot be reused directly in another application, but packet B can be reused at the same time. Package B is easier to reuse because it does not depend on other packages.
To determine package dependencies, check the relationships in the Class block diagram. If there is a relationship between classes in different packages, so does the package.
When generating package dependencies, try to avoid circular dependencies. To avoid circular dependencies, you can split a package in two.
This is the end of this article on "UML dependency characteristics and precautions". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.