question-circle [Solved] User-defined attribute types in Class Diagram?

6 years 1 month ago #1729 by parkbh
Hi

I wonder if I could use a user-defined attribute types in Class Diagram.

For example: + bg : Image
And the Image is a class not directly from a known language but a class from an external framework.

I only could use a primitive type of the Class type defined in the same UML.

Is it possible to use a type not directly available in the same UML?

Please Log in or Create an account to join the conversation.

6 years 1 month ago #1730 by ebr
Hi,

I am not sure to get your whole point but of course you can defined a new type and use it as an attribute type.

What I do not understand is what you mean by "in the same UML"!? Do you mean in the same diagram? In the same model or project!? Both options are possible but not in the same way.
If you want to use a type defined in another diagram select your attribute, in the "Element" view select its "Type" field and than enter the name of your user-defined type.
If you want to use a type defined in another model, I would recommend you to use model components

Regards,

EBR

Please Log in or Create an account to join the conversation.

4 years 10 months ago #3000 by muthuskumar
Sorry to reopen this topic again. But when I assign the type of the attribute to an user defined class, I get a warning in the Audit tab.
For example, according to the previous user parkbh's example, if I define an attribute in my class as
+bg : Image,
where Image is another class in my project, then I get the following warning -
The 'bg' attribute cannot be typed by the 'Image' Class, because the latter is not primitive.
If I go to my Image class and make it Primitive (by selecting the Primitive option in the Element tab), then I get a different warning that
The primitive class 'Image' has an association
My Image class has associations with other classes.
I don't understand the why the first warning comes up at all. I simply could ignore the warning, but I am trying to understand the logic behind it.

Please Log in or Create an account to join the conversation.

4 years 9 months ago #3006 by ebr
Of course, you can ignore the warning or even configure Modelio to unable this warning.

The reason of these warning are the following.
Let's imagine that you want to represent the fact that a class "C" has a property "p" typed by an type "T" you have two ways of doing this.
  1. Create an attribute "p" under "C" and type it with "T"
  2. Create an association between "C" and "T" with a role "p" on the "C side".

But Modelio incites you to use the first solution is "T" is a PrimitiveType or an Enumeration and the second one in the other case. This is part of uML Best Practice more than an rule on UML metamodel.

Regards,

EBR

Please Log in or Create an account to join the conversation.

4 years 9 months ago #3008 by muthuskumar
Ahh... I wasn't aware of any best practice recommendations around this. I thought both the approaches are equally usable in all scenarios.
I will go with the second approach, rather than disable the warnings.

Thank you very much for the information.

Please Log in or Create an account to join the conversation.

11 months 1 week ago #5303 by phil.soady@gmail.com
Thats a rather large claim.
An attribute that represents a complex object is marked as warning since a string wasnt used.
Making your own string object uncessarily is bad practice.
Have a model with classes and attributes that use these classes or interface is indeed best practice.
It is the warning only generated when the Interface itself isnt sufficiently complex to warrant being there ?

Please Log in or Create an account to join the conversation.

Moderators: tmaebr
Time to create page: 0.042 seconds
^ Back to Top