[UML] The simplest class diagram

Rational Rose concise and practical tutorial   https://blog.csdn.net/gz153016/article/details/49641847

Rational Rational Rose is a company produced an object-oriented a unified modeling language of visual modeling tool. Assembly configured for visual modeling and application software company-wide level. Now relatively few companies are using already Rose. IBM introduced Rational Software Architect to replace Rational Rose.

How aggregation relationship (solid diamonds) in combination with Rational Rose painting

Relationship polymerization comprising polymerizing substantially (open diamonds), and combinations polymerization relationship (solid diamonds)

Some also referred to as polymerization aggregation (open diamonds), and combinations Composition (filled diamonds)

Polymerization is a relatively loose relationship, in which ROSE generated code is the same and compositions.

Rose 2003 does not provide "a combination of relations" This graphics (solid diamonds)

1. You can first draw a relationship aggregation (hollow) a (drop-down menu bar tools ---> aggregation),

2. Then right-click on this relationship, open specification -> Role B Detail,

3. You will find that there are three option (By Value, By Reference, Unspecified), By Value in your chosen time, the diamond becomes solid.

 

 

 

 

 Double-lines, and provided Role B General Role A General

 

 

 

 

 

 

  •  A total of visibility (+): to be able to see any element of this class are visible.
  • Protection of visibility (#): visible to other elements of this class and its subclasses.
  • Private visibility (-): visible to other elements of the class.
  • Visibility package (~): visible to other elements in the same package.

 

Class relationships

Class independent rarely, the basic relationships between classes including association, generalization, aggregation, and combinations thereof.

1. relationships and dependencies

For many children's shoes just contact the UML, association and dependencies between classes might not understand, today's shallow dishes to talk about.

rely

The performance of the connection between the classes and class function parameters (use a) that represents a class depends on the definition of another class, where a class change will affect another class. For example, if A is dependent on B, then B is embodied as local variables, parameters of the method call, or a static method. The television (TV) depends on the (channel) channel common dependence as follows:
(1) A class class method B passed in as a parameter. I personally would it named "parameter dependence."
(2) Type B is present in the method of class A in the form of local variables. Personally, I named it the "local dependency."
Static property or method (3) Class A Class B's call. Personally, I would name it as "still rely on."
Implemented using a UML diagram with dashed arrows pointing to the dependent classes , as follows:

Association (delegate)

Performance variables (has a), the coupling between the class and class, it knows that the properties and methods of a class of another class. For example, if A is associated to B, then B reflected A global variable, such as company class and the person class.
Two-way and associated relationships way association:
1, bidirectional associations: two classes with each other are aware of another class public attributes and operations.
2, unidirectional association: a class knows only a further class of public properties and operations.
Most of association should be one-way, one-way relationship easier to build and maintain, help to find may be taking classes.
UML diagrams implemented using a solid line (in some places with solid lines with arrows ) connecting same or different classes, as follows:

       This is indeed a bit of a mess, but the dishes suddenly found a good entry point, come to share it.

       Contact reader design patterns will often see this scenario: when the instance of class A, class B requires as argument constructor, which is required to hold Class A description of a referenced class B. For example proxy mode, decorative patterns, etc., do the same. For example IO streams Java is used in decorative patterns, so we will often see such a sentence: new BufferInputStream (new FileInputStream ( "c: \\ 1.db"));

Relationship between the person and the company, also known as delegated relationship (I called it).

       This holds references, it is a simple relationship. Performance in the code is: There is a member variable in class A, the type of the variable is a class B, class A holds a reference to the class B, it shows Class A and Class B occurred relationship .

       UML FIG represented as follows:

       Little explanation, since A Class B Class holds a reference is emitted from the thus associated category A (caused by class A), so the arrow points to Class A Class B from.

       Under normal circumstances, this unidirectional association simply enough, but the association is mainly used in database design.

       In database design, whether it is one to one, one to many, many to many, not one-way.

       From the angle of the table, the other end of which can be determined from either end. Take many people, having one end of the primary key, can find many end data according to many foreign key table end; end with many foreign key, one can find data terminal according to one terminal of the primary key table.

       From the analysis entity class, the other end can also be determined from either end. Or take many terms, the one end of the entity class will hold a set many reference terminal, e.g. private Set <B> bs ;, query to one side, can be read many direct mode from the set; many end entity class will hold one end of a reference, for example, private a a ;, query to many end, many may be determined for each of the one end side from this direct reference.

       As a result, it becomes a two-way association with the UML painting relationship when both sides of the arrow will be added, so too difficult to see, we simply do not add up.

       Sector entities such as the relationship between class and the staff of the entity class, you can say so:

 

       As is the relationship between the database entity classes, plus the number of relations, represents one end, 0..n on behalf of many ends, indicating a department can have multiple employees, but an employee can only belong to one department, by many UML diagram is described.

       A typical application of this is the relationship.

       We must mention that the association may also be subdivided and polymeric compositions (both specific concept of the reader to search).

       Found dishes polymerization composition can be understood from another angle.

       First talk polymerization, which is a weak association, and probably means that the whole portion can exist independently. If we change the angle, it can be seen as a cascade operation of the database.

       Take the team and the team members, it's time to delete a group, the members of the group are also deleted, which is obviously unscientific, because team members and is a weak association, teams can have as a team member , one component may be to any of a group, this group does not exist, can go to another group, they are not necessarily associated, it can be referred to as polymerization.

       Therefore, we designed the database, it is often not set up cascading deletes, that are not deleted when you delete group members.

       UML diagram showing the following:

       Open diamonds represents the polymerization, one end point.

       Let me say a combination, the combination is a strong correlation, probably means the whole and indivisible part, can not exist independently. Same manner as understood from the cascade.

       Take for students and student cards, if a student dropped out, no longer belong to this school, consider the student information Delete to delete the time, student ID information corresponding to the student will be deleted, where you can add cascading deletes. Because the student ID card belonging to proprietary information about a student, the student does not exist, student cards do not let others use, it is a strong correlation can be called a combination.

       UML diagram showing the following:

       Finally, to talk about the dependencies.

       If a method of class A, a class B, then A is said to depend on the class Class B, which are dependencies.

       A method of using a class of Classes B, may be the parameters of the method is Classes B, may also be obtained in the instance of a class B method. But in either case, class B to class A are local variables present form.

       Thus, there are local variables A class of type B, said A class depends on Class B.

       UML diagram showing the following:

       Dashed arrows indicate dependency, arrows pointing to the dependent classes.

       In summary, there is a simple judgment principle: a class member variables in the form of another class, both the association relationship; in the form of a class in another class of local variables, both dependent relationship.

       Note: This article for the convenience of explanation, has been to take the class as an example, this is not a good design thinking. The actual development, in order to better achieve the "open - closed principle" are generally defined interfaces, depending on the interface depends on the abstract, rather than depending on the program, I hope that readers will not be misled side dishes! !

 Original link: https://www.cnblogs.com/igoodful/p/9441316.html

 

 

Association relationship performance variables (has a). Coupling between the class and class, it knows that the properties and methods of a class of another class. For example, if A is dependent on B, then B is A reflects global variables. Two-way relationship and association unidirectional association. Bidirectional associations: two classes are aware of another class of common attributes and operations. Unidirectional association: a class only knows another class of common attributes and operations. Most of association should be one-way, one-way relationship easier to build and maintain, help to find may be taking classes.

 

 

 Reference Links: https://blog.csdn.net/wdjxxl/article/details/79608796 

2. The composition and the polymerization

Diamonds represent the meaning 全体 - 部分of the relationship. That Whether solid or hollow, represent 全体 - 部分 /  part - of meaning.

  • Hollow, and the connector portion may all be relaxed, representing the relationship between the polymerization, and all portions may exist independently from each other.
  • Solid, and the connecting portion all are strongly correlated, the relationship between the representative combinations. Combinations are also associated with a relationship of a relationship stronger than the aggregation relationship. Part class composition relationship can not exist in the whole class. The whole class and some classes have the same life cycle.

 

 

 

Reference Links: https://blog.csdn.net/huuinn/article/details/78176946

 

 

3. Generalization

In the figure, the hollow triangle denotes inheritance (class inheritance), in terms of UML, this relationship is called generalization (Generalization). Person (person) is the base class, Teacher (Teacher), Student (student), Guest (guest) is a subclass. 
If B is logically "an" A, and all the features and attributes of A for B have meaning, B is allowed inheritance and attribute A. 
For example, teachers are people, Teacher is the Person of "an" (a kind of). Teacher can then class (inherited) derived from class Person. 
If A is the base class, the derived class A is B, then B and the data will inherit function A. 

If the class A and class B irrelevant, not in order to make some more functions B and let B of A inherited functions and properties. 
If B is logically "an" A, (a kind of), B is allowed, and inheritance attribute A. 

 

 

 


Reference link: https: //blog.csdn.net/gz153016/article/details/49641847

 

Guess you like

Origin www.cnblogs.com/aidata/p/11450229.html