UML for nearby OCaml objects

I created an immediate object in OCaml.

let x = object (self) val dataMember = 3 method aMethod = print_endline "Called a method" end;; 

How does an object have no name (is it considered anonymous?), How can it be correctly represented in UML?

Thanks.

+3
source share
2 answers

You can give it the name nonce or some other formula value. “Correct” in this context really means something that will be clear. There is no “right answer” transmitted from the UML International Standards Authority or anything else.

If you need a more specific answer, why not name it something like Anonymous_foo_mungler , where " foo_mungler " is replaced by a descriptive name that you would give if it were not anonymous.

+3
source

Here is what I found. I will just follow the image below (if possible), but discuss first. Naming something in UML does not mean that it cannot be anonymous in the implementation. I struggle more with the fact that it is “inside” of another class more complicated, therefore the line of package / component inclusion, which is used below. You can also use an instantiated connection to show what you are looking for. You can also use components as they allow inclusion. In the end, although I am torn, why would you model an anonymous class, because it is not part of the structure, since you never refer to it outside the class (IN GENERAL), but more on behavior. Thus, why instances and properties allow anonymous elements. If you start modeling LISP, etc., this question will become really funny.

Updated for UML 2.0: Anonymous Class Example http://www.informit.com/content/images/chap3_0131428489/elementLinks/03fig22.gif

Note that in Figure 3.22 and that the author says “Stereotype”, which is incorrect because it is not part of the language, therefore it is a keyword, which means not any part of the formal model, any old line. Not all tools support notation, but RSA / RSM does my surprise and uses something close to notation.

Source page - http://www.informit.com/articles/article.aspx?p=336264&seqNum=3

From the UML specification itself:

For properties - A property symbol may be displayed containing only one name (without a colon) in its name string. This implies defining an anonymously named class nested in the namespace of the containing class. The part has this anonymous class as its type. Each appearance of an anonymous class is different from any other event. An anonymously defined class has the properties specified with the part symbol. It is allowed to display compartments defining attributes and operations of an anonymous named class.

For instances - (Names are optional for instances) The standard notation for the specification of an anonymous instance of an unnamed classifier is the underlined colon (":). If the instance specification has a value specification as its specification, the value specification is displayed either after the equal sign (" = ") after name, or without an equal sign below the name: If an instance specification is shown using a closing form (for example, a rectangle) that contains the name, the specification of the value is Rage in the form of closing.

+4
source

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


All Articles