Create vs. Instantiate Dependencies in UML

According to the UML specification, we can denote the relationship between two classes using the stereotypes <<Create>> or <<Instantiate>> .

Do you know the differences between these stereotypes?

This is written in the UML 2.5 specification (chapter 22.3 Standard stereotypes):

  • For <<Create>>

    Usage dependency, indicating that the customer classifier creates instances of the supplier classifier

  • For <<Instantiate>>

    Classifier usage dependency indicating that client operations create provider instances

+4
source share
3 answers

I noticed that the <Create → stereotype can also be applied not only to the Usage dependency, but also to BehavioralFeature (see Section 22.2 in the UML specification).

In UML, "BehavioralFeature" corresponds to specific methods in a class or interface.

Therefore, if we mark a specific method in a class with <Create → or <Destroy → we mean that it creates / destroys instances of this class.

We can draw a parallel between marking the method with <<Create → and marking the usage dependency with <Create →.

If we note the usage dependency on <Create> then this means that the particular method in the client class creates an instance of the provider class. Therefore, we instantiate the provider in the body of our customer class. Customer and supplier are closely related here.

On the other hand, if we note a usage dependency on <Create, the Client Class delegates the creation of the Provider to other objects. Therefore, he creates the Supplier indirectly. In this case, the Client and the Supplier are loosely coupled. For example, this happens if we create a provider through one of the creation templates: object pool, prototype, Factory method, etc.

Note:

By and large, the differences in the specification are not entirely clear. Hope in future releases (over 2.5 version) has clearer definitions.

+1
source

Michael Jesse Chonoles Yes, "create" is used in sequence diagrams. This is a stereotype in the message. “Create” is also a stereotype of a behavioral function in the classifier, indicating that it is an constructor of instances of this classifier (or the equivalent for objects that are not object-oriented).

When Create is used for dependency, it is not like Instantiate. Personally, I use the "Instantiate" dependency. When I mean a true object-oriented creation called by a constructor call (how would I translate the model into code). I would use Create when it is a different kind of creation, more indirect, conceptual, or non-object oriented functions.

Here are some examples. I would use “Create” to say MSWord → “Create” Document, the designer “Create” a model. Although I usually will not simulate this in detail, I would use "Create" to indicate the "Create" component to a new database record, the database manager "Create" a new database, the programmer "Create" a new application. Or create a new element in an array (non-oo). This can happen without a direct call to the traditional object-oriented constructor and cannot be directly converted to code.

On the other hand, if I had an operation to marry a person, it would most likely “create” an object of the association class in marriage.

Since most of my models are conceptual, in practice I usually use "create". Although, even then it does not occur so often.

+2
source

The person who instructs me on SyML / UML has been involved in MSBE SyML / UML for large companies for many years.

I asked him how to draw a diagram that shows:

The "System boot process" loads (from ROM) and launches the "BASIC process / system application".

He said that I should use the Create dependency on usage.

So, as I see it:

  • You use "Create" to show that one process is launching "big" things - for example, loading the entire external process / SW element / application.

  • You use "Instantiate" to show that in this process, the Segment code creates an instance of the "object" of the object from the definition class.

0
source

Source: https://habr.com/ru/post/1233943/


All Articles