user907860 user907860 - 4 years ago 73
Javascript Question

How to show an object provided as an argument by a user on a UML class diagram?

I have a JavaScript function, which is supposed to act like a class, and it needs several pieces of data from a user.

I decided to make it to expect one single object with those data pieces as its arguments, like:

new ClassFunction({
arg_1: 'foo',
arg_2: 'bar'
});


What is the best way to show this on a UML class diagram?

Should I write it as a comment in the curly braces or as a separate note or as an abstract class with a dependency line from the constructor class (ClassFunction) to that abstract class?

Or may be something else?

Answer Source

JavaScript function, which is supposed to act like a class

The more proper term would be object constructor; this may also give you a better idea of what you are actually trying to do.

Now the parameter provided to the constructor is some anonymous class that understands arg_1 and arg_2. UML models this via DataTypes, denoted with the <<dataType>> keyword.

A DataType is a kind of Classifier. DataType differs from Class in that instances of a DataType are identified only by their value. All instances of a DataType with the same value are considered to be equal instances. [UML Spec 10.2]

So for example your case could be modeled as the following:

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download