Sparx Enterprise Architect: Show programming language in component diagram

Viewed 121

I am using Sparx Enterprise Architect and am somehow confused that I did not find any hint on the internet regarding the following question: How can I show the programming language of a component in the component diagram?

It is clear to me that I could use custom stereotypes but this is not a good idea as it prevents me from using "real" stereotypes later on.

2 Answers

The reason is simply that you can not show it using EA's GUI. You would need to stereotype the element and come up with a shape script to display the language with a

print("#language#");

somewhere.

To assign a shape script to a stereotype there are two ways, the quick and dirty and the difficult one. Here's the q&d one:

Under Configure/UML Types you can add a new 'wild' stereotype. That is one with no profile. EA will show that as <none> when applied. Think of a fitting name and choose Edit with the shape script:

enter image description here

Here can enter the new shape script (since this depends very much here's a simple one):

shape main {
  Rectangle(0, 0, 100, 100);
  println("#name#");
  println("#language#");
}

Save the edit and close the dialog. Once you assign the stereotype to an element it will render like this:

enter image description here

I know this is not pretty and you need to dig into shape scripts to make it useful, but that can't be avoided.

So the difficult, but better and preferred, way is to create your own profile containing the stereotype along with the shape script. The above would just be a way of testing it but finally you would need to create your profile and put it in a MDG. Since this is a quite complex task it won't go here into this answer (no, I'm not Fermat, but you need quite some effort to get that far).

There is no standardized way to show the programming language of a component in UML. There are several ways you can do it, for example:

  1. Stereotype. This will not prevent you from adding other stereotypes in the future. Multiple stereotypes are shown comma separated: «stereotype1, stereotype2»

  2. Generalization. You can define a component called 'JavaComponent' and let all Java components inherit from this base component.

  3. Note. You can attach a note to the component specifying the language.

Related