Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is it recommended to make associations to enum classes in uml class diagram?

I am designing a class diagram and I got a doubt:

I have a class which have several attributes referring to Java enums and other classes that will be mapped as DB catalogs.

For example, there is a class called BankAccount which has an attribute called type:BankAccountType (enum) and other which is bank:Bank (catalog class).

Is it recommendable to mark the association between classes or it can be obviated? If yes, should they be aggregated (a BankAccount HAS a bankAccountType) or simply associated?

like image 607
htafoya Avatar asked Sep 15 '11 01:09

htafoya


People also ask

What are the best practices in representing UML class diagrams?

UML Best Practice: There are no Activities on an Activity Diagram. Short Don't use Activities on an Activity Diagram Purpose Model useful and UML compliant Activity Diagrams Detail UML Activity Diagrams are often used to depict a certain flow of events.

What is the purpose of an association class in UML class diagrams?

In UML diagrams, an association class is a class that is part of an association relationship between two other classes. You can attach an association class to an association relationship to provide additional information about the relationship.

What is enumeration in UML class diagram?

In UML models, enumerations are model elements in class diagrams that represent user-defined data types. Enumerations contain sets of named identifiers that represent the values of the enumeration. These values are called enumeration literals. You can add enumerations to depict discrete sets of values.

What is the purpose of the association relationships in the class diagram?

Relationships in class diagrams show the interaction between classes and classifiers. Such relationships indicate the classifiers that are associated with each other, those that are generalizations and realizations, and those that have dependencies on other classes and classifiers.


1 Answers

Regardless of whether the attribute type is an enum, there are two ways to represent attributes in UML: as proper attributes, and as directed associations.

The two ways of representing attributes in UML

The two styles of attribute declarations are semantically equivalent: they mean exactly the same thing. In other words, which one you choose comes down to a matter of style.

Using attributes makes for a simpler diagram, and in some tools is required in order for the attribute to be visible in the tree view of the model.

Using directed associations means you must include the target type (the enum) in the diagram, which means you can see the literals. Of course, you can include it in the other case too, as I've done with An_Enum above.

I don't normally use aggregations or compositions for code-level modeling; I feel they're better suited for describing more abstract relationships between classes (as in an information model) and conceptually they don't really match anything in source code. Attributes do, possibly supplemented by "dependency" or "use" relationships to classes which are used as local variable types or whose methods are called.

like image 163
Uffe Avatar answered Oct 12 '22 20:10

Uffe