UML meaning the code

Class (Class)

Class ( FIG. A ) is a blueprint for the object, which contains three components. The first is the Java class name defined. The second property is the (attributes). The third method is provided by the class.

A visibility modifier can be attached before the attributes and operations. Plus sign (+) indicates a common visibility. Minus sign (-) represents private visibility. # Sign indicates the visibility protected. Omitted visibility modifiers represents a package (package) level. If the property or operate underlined, indicating that it is static. In operation, may also lists the parameters it accepts, as well as the return type, "Java" region A shown in FIG.

Figure A

 

 

 

Follicles (Package)

Package (FIG. B ) is a combination of general-purpose mechanism. A UML package corresponds directly to a package in Java. In Java, a package may contain other packages, containing both classes or both. When modeling, you usually have a package logical, it is mainly used to model your organization. You will also have a physical package, which is converted directly into the system Java package. The name of each package of this package uniqueness of identity.

Figure B


Interface (Interface)

Interface ( FIG. C ) is a collection of operations that specifies a service class provided. It corresponds directly to an interface type in Java. An interface that can be represented by an icon of FIG C, may also be added << interface >> class to represent a standard. In general, according to the interface looks like on a class diagram, you can know the relationship with other classes.

Figure C

relationship

Examples of the latter will be independently show the relationships for a specific purpose. While the syntax is correct, but these examples can be further refined to include more semantics within their effective range.

Dependence (Dependency)

After a "using" relationship specification implies a physical change between the entities, which may affect other instances depend on it ( FIG. D ). More particularly, it can be converted to any type of reference example not within the scope of a class or object. It includes a local variable, a reference to the object obtained by the method invocation (as illustrated), or references to static methods of a class (an instance of that class the same time does not exist). It may also be utilized "dependency" to represent the relationship between the package and package. Because the package contains the class, so that you can be a relationship between the various classes of those packages, and shows the relationship between the package bag.

Figure D


Association (Association)

A structured relationship between the entity indicates that the object is interconnected. Arrow is optional, it is used to specify navigation capabilities. If there is no arrow, suggesting a two-way navigation capabilities. In Java, an association ( Figure E ) is converted to an instance variable scope, as the code "Java" region of FIG E as shown. Other modifiers can be added to an association. Multiplicity (Multiplicity) modifier implies that the relationship between the instances. In the exemplary code, Employee may have zero or more objects TimeCard. However, each TimeCard only belong to a single Employee.

Figure E

Polymerization (Aggregation)

Polymerization ( FIG. F. ) Is a form of association, global / local representative of the relationship between two classes. Implies that the entire polymerization in a conceptual level higher than the local, suggesting the association of two classes in the same level in the concept. The polymerization may also be converted into a scoped instance variables in Java.

The difference between correlation and aggregation of purely conceptual, and reflected in the strict semantics. Examples of the polymerization also implies that the loop does not exist in FIG. In other words, only a one-way relationship.

Figure F



Synthesis of (Composition)

Synthesis of ( FIG. G ) is a special form of the polymerization, suggesting a "local" survival "Whole" internal duty. Synthesis is also non-shared. So, although not necessarily with the partial destruction of the whole is destroyed, but the whole or partial responsible for maintaining the survival of the state, or be responsible for their destruction. Not shared with other local overall. However, the overall ownership can be transferred to another object, which then will assume the duties of survival.

Employee relations and TimeCard perhaps better suited represented as "synthetic", rather than, say, "association."

G in FIG.

Generalization (Generalization)

Generalization ( FIG H ) shows the relationship between the elements of a more general and a more specific element. Generalization is the UML elements are used to model the inheritance. In Java, use extends keyword to indicate a direct relationship.

Figure H


Realization (Realization)

Example ( FIG. The I ) relationship specifying a contract between two entities. In other words, an entity definition of a contract, while another entity to ensure fulfillment of the contract. When a Java application modeling, the relationship can be achieved directly implements keyword to represent.

图 I


Reproduced in: https: //my.oschina.net/lendylongli/blog/226785

Guess you like

Origin blog.csdn.net/weixin_34409357/article/details/92576602