attributes and fields

10 views
Skip to first unread message

Agostino

unread,
Apr 5, 2021, 2:57:11 AM4/5/21
to UML Forum
I've got two questions about attributes of classes in class diagrams. 
The first is: does an UML attribute map exactly to a class field?

The second is somewhat related to the concept of field; in some languages (C#) we have the concept of property. This is just an hidden couple of methods that mimic the field syntax while offering the setter/getter benefit for additional logic. This corresponds to setXXX getXXX methods in java. 
Now, should a property be considered an operation, following their nature of methods or an attribute following its similarity to fields?

Maybe the answer could be 'it depends'? A formally correct way would be the first, while at the same time this representation in some cases could be too informative, showing details not relevant for the model. 
This is, sometimes I want to know that the property "Height" is backed by a private field height, sometimes it's obvious or irrelevant and this would simply pollute the class description with irrelevant information. In this second case I include it in the attributes, knowing that is not implementation accurate (a property can be virtual, can execute additonal logic etc.etc.)
What are you thoughts about this?

Reply all
Reply to author
Forward
0 new messages