美文网首页Engineering
[UML] 类之间的关系

[UML] 类之间的关系

作者: 何幻 | 来源:发表于2017-02-07 16:54 被阅读5次

    Graphic paths (P148)



    1. Aggregation & Composition: AggregationKind(P39)

    AggregationKind is an enumeration type that specifies the literals for defining the kind of aggregation of a property.

    AggregationKind is an enumeration of the following literal values:
    (1)none:Indicates that the property has no aggregation.
    (2)shared:Indicates that the property has a shared aggregation.
    (3)composite:Indicates that the property is aggregated compositely, i.e., the composite object has responsibility for the existence and storage of the composed objects (parts).

    2. Association(P40)

    An association describes a set of tuples whose values refer to typed instances. An instance of an association is called a link. A link is a tuple with one value for each end of the association, where each value is an instance of the type of the end.

    An association specifies a semantic relationship that can occur between typed instances. It has at least two ends represented by properties, each of which is connected to the type of the end. More than one end of the association may have the same type.

    An association may represent a composite aggregation (i.e., a whole/part relationship). Only binary associations can be aggregations. Composite aggregation is a strong form of aggregation that requires a part instance be included in at most one composite at a time. If a composite is deleted, all of its parts are normally deleted with it. Note that a part can (where allowed) be removed from a composite before the composite is deleted, and thus not be deleted as part of the composite.

    Compositions may be linked in a DAG (directed acyclic graph) with transitive deletion characteristics; that is, deleting an element in one part of the graph will also result in the deletion of all elements of the subgraph below that element.

    3. Dependency(P65)

    A dependency is a relationship that signifies that a single or a set of model elements requires other model elements for their specification or implementation. This means that the complete semantics of the depending elements is either semantically or structurally dependent on the definition of the supplier element(s).

    A dependency signifies a supplier/client relationship between model elements where the modification of the supplier may impact the client model elements. A dependency implies the semantics of the client is not complete without the supplier.

    The presence of dependency relationships in a model does not have any runtime semantics implications, it is all given in terms of the model-elements that participate in the relationship, not in terms of their instances.

    4. Generalization(P75)

    A generalization is a taxonomic relationship between a more general classifier and a more specific classifier. Each instance of the specific classifier is also an indirect instance of the general classifier. Thus, the specific classifier inherits the features of the more general classifier.

    A generalization relates a specific classifier to a more general classifier, and is owned by the specific classifier.

    Where a generalization relates a specific classifier to a general classifier, each instance of the specific classifier is also an instance of the general classifier. Therefore, features specified for instances of the general classifier are implicitly specified for instances of the specific classifier. Any constraint applying to instances of the general classifier also applies to instances of the specific classifier.


    Association vs Dependency

    An association almost always implies that one object has the other object as a field/property/attribute (terminology differs). A dependency typically (but not always) implies that an object accepts another object as a method parameter, instantiates, or uses another object. A dependency is very much implied by an association. ——Difference between association and dependency?


    参考

    Object Management Group Unified Modeling Language, Superstructure

    相关文章

      网友评论

        本文标题:[UML] 类之间的关系

        本文链接:https://www.haomeiwen.com/subject/lcupittx.html