UML class Brief

UML, describing the relation between class and class, classes and interfaces, there are represented the following description:
Composition - synthesis
Aggregation - polymerization
Association - association
Dependency - dependent

These four relationships correspond to different business background, above the display, in accordance with the scope of the corresponding business context of these relationships in ascending order of (a lot of network resources with the "strength" to describe the relationship between these four the difference, I do not think this is accurate to describe, at least in my opinion, the word "these relations correspond to the actual business background" compare "the strength of the relationship between these four" more vivid, easy to understand).

The following is an analysis with examples as well as for example:
24005233_GOky.png Synthesis: composiation 

There are three categories, namely, a wheel, a tire tread, tire tube.
The specific code as follows, of course, the following code can not be placed in the same java source files (smart you know this is why you?)
   
  1. public class 轮胎内胎 {
  2. public String 内胎牌子;
  3. }

  4. public class 轮胎外胎 {
  5. public String 花纹样式;
  6. }
  7. public class 车轮 {
  8. private 轮胎外胎 外胎;
  9. private 轮胎内胎 内胎;
  10. }
Each wheel comprises a tire casing and the inner tube at least, are indispensable, then the UML diagram, the relationship between the wheel and the tire, the inner tube, it is described by a combination --composiation, and filled diamonds represent the end combined into classes, in the present example, is combined into a class [wheel].
In addition, we can also think of other examples, for example, there is a class called Bird, then the property should have a Head, then this time, the relationship between these two classes is a combination.
24005233_GOky.png Polymerization: Aggregation
Now we turn our attention to the red part of the frame of mind

Mercedes-Benz wedding team this class, is certainly a lot of Mercedes composed, this is the aggregation --aggregation.
Difference between the polymerizable composition, can be seen here:
1, focusing on the combination, and is *** *** *** the composition, once drawn in UML, the indispensable, and the polymerization is polymerized from many *** *** formed , a small two all right
24005233_GOky.png Association: association
 Then look at the association, as shown below, and now we are still concerned about the contents of the red frame of mind:


Benz car seats, luxurious soft leather upholstery, this is related, because if this cushion in the event of changes in the class, the Mercedes-Benz car seat is also sure to follow the change. So this association and combination of what difference does it?
1, there is not a non-association is not, but the combination must be stressed that must include, Mercedes-Benz does not necessarily have to have the luxury of soft leather cushion, as it may some Diamond Edition hard seat or even none.
Then the correlation and aggregation so what difference does it make?
1, both the focus on different business background, polymeric composition is represented by a lot of ***, and associated only that there is such a thing, this thing is not a necessity. From this point of view, they are not comparable.
24005233_GOky.png Dependent: dependency
The last is dependent on a relationship, and to not look at pictures, tell you, BenzCar dependent classes weather.
What? This is what with what? Why would I have a car-dependent relationship with the weather?
Look at the following UML diagram it, or concerned about the red part


Now you understand, right?
Wipers swing or not directly affected by the weather, but no effect on the car itself, just a function of vehicle impact.
Then we can understand the weather does impact on the car, but the car just in terms of the impact that ass big impact, and this is a big fart lack of influence exists, at the same time, and so on:
1, I will need to take into account what day it is, whether to limit the odd and even numbers on the road;
2, there are no gas stations open for business today, because I have to refuel
3, whether there are parking spaces mall today, because I'm going to the mall parking
…………
And so on, these are indeed the impact categories: BenzCar, but the impact was so kind of looks like it does not matter with the BenzCar, this dependence is called, this is like a computer and then how to imitate reality, are not the whole of imitation to reality, therefore, this is termed the dependent UML.
Because of these factors too much, therefore, rely on this relationship in UML, the scope of the business context of the corresponding is the most widely used.
If you have more dependent and associated differences:
1, the impact is not dependent on the class, but the class of some methods, the correlation is affected by this class.





Reproduced in: https: //my.oschina.net/u/1182369/blog/405719

Guess you like

Origin blog.csdn.net/weixin_33729196/article/details/92083700