Nov 142016
 

You might already thought about tracking metrics based on model data. However how difficult is to create your own metric?

Using MagicDraw metrics capability and structured expression dialog to setup almost any metric logic and calculate it requires no coding.

If you already using structured expression dialog to query model for derived properties or smart package it is definitely nothing new for you. Even if you do not, simple query is as simple as find results. But how to convert result as list of the elements into number?
It is simple. JavaScript function to convert list of elements into number is:

arg.size()

Here are couple of examples of metric logic specification using structured expression dialog and converting result into number (size). For “How To” check video and download sample project file at the end of this post.

Figure 1. Converting Metachain Navigation query results into number.

Figure 1. Converting Metachain Navigation query results into number.

Figure 2. Calculating percentage requirements covered by satisfy relation.

Figure 2. Calculating percentage requirements covered by satisfy relation.

Resulting metrics look like this:

Figure 3. Metric results.

Figure 3. Metric results.

 

Metric specification:

Figure 4. Metric Specification.

Figure 4. Metric Specification.

Model under analysis:

Figure 5. Model under analysis.

Figure 5. Model under analysis.

Derived Properties

Same method can be used for derived properties also to convert from list of results into number.

Figure 6. Number of Satisfy relations requirement has.

Figure 6. Number of Satisfy relations requirement has.

Download sample project file to find described metric and derived property cases.

Video covering steps how to create derived property, metric, and convert to number:

5.00 avg. rating (98% score) - 1 vote

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

Time limit is exhausted. Please reload CAPTCHA.