Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: Guillaume on June 10, 2014, 11:10:49 pm
-
Hi,
Is there any way to keep a class stereotype when creating an instance?
I have "client" and "server" stereotyped classes ; when creating a lifeline on a sequence diagram, can I tell EA to apply the class "client" or "server" stereotype on the instance/lifeline?
thanks
-
You can assign it manually. However, I think that the stereotype from the classifier should be applied automatically. Looks like a bug to me, but I'm not that firm in the Superstructures. Maybe someone from Sparx could comment.
You should report that as bug anyway to see what they state officially.
q.
-
In general a stereotype on a classifier can't be applied to an instance because the instances are a different type of element.
However, in general the appearance of an instance is intended to match that of the classifier. (But with underlined name and : <classifier>) From the top of my head I don't know if the specification is explicit about displaying stereotypes from the classifier. It may be that it is appropriate to draw the stereotype even though it isn't explicitly defined.
-
At least EA is consistent in the way they apply that pattern. If you create an instance of a class the stereotype isn't copied too. Geert seems to be absent at the moment. He might have more insight in what OMG meant to happen in this case.
q.
-
I think that copying the classifier's stereotype to its instance should be optional so this is more an enhancement request than a bug report.
e.g when creating an instance of a class, EA would prompt the option "Apply the classifier's stereotype to the instance" (default value : disabled).
-
I guess that way would make everyone happy. But on a short term that means you'd need to script that with an add-in listening to some of the OnPost events.
q.
-
It is possible to do this in a profile. Search the help for "_instanceType" for details.
In short, what you do is define a stereotype that extends "Class" (or any other classifier type), define a stereotype that extends either "Object" or "Part", and give the first stereotype an attribute "_instanceType" that names the second stereotype. There's more to it than that, but it's all in the help...