UML class diagram design - uml

I am trying to implement the UML class diagram for the first time. This is the class diagram which I have been work through:
This is the requirement:
I do not expect anyone do it for me, but I think I need someone help to check where I can improve or I anything is missing. Thank You.

A class diagram is a structural diagram. Behaviors (e.g. adding, deleteing, etc...) shall not appear therein, except if you decide to make them operations of one class.
Here how to understand the requirements:
R1. Classes GroceryList, Item and User. Association between 0..n GroceryList and 0..n Item. Association class with property Quantity
R2. Class ItemType
R3. Association between 0..n Item and 1 ItemType. Both classes have a property Name
R6. Association class also has property CheckOff
R10. Association between 1 User and 0..n GroceryList. GroceryList has a property Name
Assumption: User has a property Name
If your teacher never told you what an association class is, then use a class ListItem instead, with an association of 0..n ListItems with 1 Item, and a coposition link from GroceryList to ListItem
Remove any other box in your diagram, because these are either behaviors, or a duplicate of an existing class.
For the operations, it is not clear to me because it depends on the architecture of your application (e.g. will you use repository classes?).

Related

Add Association Class to Composition relationship

I'd like to know if it is correct to add an Association Class to a Composition relationship?
For example (see figure below), can I add an Association Class (i.e. NameValue class) to the composition relationship between Name class and Value class? One Name can have multiple Value and one Value can only be attached to one Name. NameValue class stores the name-value pairs.
The reason why I create the association class (i.e. NameValue class) is that I need to create associations/relationships between NameValue class and other classes such as Class A.
If the answer is yes, is it recommended to turn the association class into a normal class?
Many thanks!
I'd like to know if it is correct to add an Association Class to a Composition relationship?
yes in an association-class the association can have an owner-end property being a composition, in formal/2017-12-05 there is nothing in § 11.5.3.2 Association Classes starting page 200 nor in § 11.8.2 AssociationClass [Class] against that even association-class has some constraints
NameValue class stores the name-value pairs.
note this is absolutely not the goal of the class of an association-class in UML, and not necessary the case when you implement an association-class
The reason why I create the association class (i.e. NameValue class) is that I need to create associations/relationships between NameValue class and other classes such as Class A
because NameValue is used at implementation level to stores the name-value pairs and then to implement the association(-class), in UML the diagram you want is :
(NameValue does not exist at UML level but only at implementation level)
If the answer is yes, is it recommended to turn the association class into a normal class?
At UML level the association-class do not exist for nothing, they make the model clear, so I do not recommend to not use class-association (but this is of course opinion-based)

Questions regarding directed association link in class diagram

I have three questions on directed association link inside a class diagram.
here is a screenshot of what i did. i am using modelio.
Description of screenshot:
The screenshot shows a class "Dress" linked by a directed association link to an enumeration named "TypeOfClothes".
On the arrowhead side (near the enumeration) there is a multiplicity of 1 and public attribute named "TypeOfDress" is specified
On the non arrowhead part of the association there is a multiplicity of *
Under the class Dress, the public attribute "typeOfDress" of type "TypeOfClothes" is also specified
here are my questions:
1: When two class or a class and an enumeration are linked together with a directed association link like here what does the multiplicity under the none arrowhead part of the association means ?
2: From what I understand, the attribute above the association means the same thing as the attribute under the class typeOfDress. however there is no attribute created in the model when given only with association. Am i wrong somewhere ?
3: If I had an attribute given on the none arrowhead side of the association what would that means ?
I hope it's understandable, if not, please tell me what I can improve :)
Thank you for your help and have a nice day!
1: When two class or a class and an enumeration are linked together with a directed association link like here what does the multiplicity under the none arrowhead part of the association means ?
the fact the relation is not navigable from TypeOfClothes to Dress does not imply it is not possible to have a restriction on the number of instances of Dress associated to TypeOfClothes. So the multiplicity is given and being here * that means any number from 0.
2: From what I understand, the attribute above the association means the same thing as the attribute under the class typeOfDress. however there is no attribute created in the model when given only with association. Am i wrong somewhere ?
it is legal to show both an association and an attribute having the same name in the class diagram, even this is redundant and only one of them is enough. From the standard formal/2017-12-05 page 206 :
Figure 11.31 shows that the attribute notation can be used for an Association end owned by a Class, because an
Association end owned by a Class is also an attribute. Although it would typically be suppressed on grounds of
redundancy, this notation may be used in conjunction with the association notation to make it perfectly clear that the
attribute is also an Association end.
An attribute is an owned property, so if your class own the property you have the attribute even you do not mention it in the attribute compartment
3: If I had an attribute given on the none arrowhead side of the association what would that means ?
the relation is not navigable in that direction, so if you add a name near * it is just informative, it is not a property of TypeOfClothes, so better to not have it
Out of that typeOfDress is public because of the +, are you sure you want that ?

Any modifications i should do on this class diagram?

I'm working on a class diagram of a simple project.
Here's a basic description of it:
"usuario" is the 'user class'. From it, i can have "membro_coral, "Membro_comissao" and "Administrador". "membro_coral" can post some news on the web site, but it goes through an avaliation to see if it can be posted or not. "Membro_coral" has a "perfil" associated with it.
There's the "evento" class. It's a class for mapping events. Users can give their disponibilities to attend to some events. And "escalacoes_disponibilidades" is the junction table.
I've added Three classes corresponding to the "Perfil" values. Some people are "membro_comissao", some people are "membro_coral" and actualy, only one is the "Administrador".
Is this class diagram right? Any modifications i should do?
EDIT: i've update my class diagram. I've added the "Status_Noticia" class. It's associated with noticia. I've done this in order to improve the statemachine diagram of "Noticia" (there's an use case which an user can send news to de displayed, but it goes through an avaliation process).
It's mostly correct. There are some minor observations however:
Membro_comissao, Membro_coral and Administrator are kind of users, right? If so, you should do one of the following: a) derive all 3 classes form user, or b) create a new class (enumerator) TipoUsuario, with those 3 values. Which option to implement depends on if there are some special features that make the 3 different one from another (some different attributes, methods or maybe associations (see the next point)
You said: " "Membro_coral" has a "perfil" associated with it.". Than this class should be associated with PErfil and not otherwise. This could be a reason to apply the option a) from before. This association should be a normal assoc. and not a composition
So, the main decision you must take is how to model user types.

UML - BCED Approach

I have a question for you.
In the BCED approach, whe have 4 package (Boundary, Control, Entity, Database), in which there are many classes with some responsability. Who is responsible to istantiate and destroy objects in the Entity package? Control's objects or Entity's object?
I'll explain better.
For example, we have 1 controller class and 2 entity classes, linked to each other by an association. Suppose that we have to use the 2 objects of 2 separated classes in the entity.
So, the controller class istantiate both object of the entity like this:
//In the controller:
create_objects(){
Entity1 e1=new Entity1;
Entity2 e2=new Entity2;
}
or the controller istantiate only the first class object that instantiates, in turn, the second class object (I remember to you that the entity classes are linked!!), like this:
//In the controller:
create_objects(){
Entity1 e1=new Entity1;
}
//In the Entity1:
create_object_2(){
Entity2 e2=new Entity2;
}
Thank you in advance and sorry for the English! :)
BCED is an architectural view at the Model-View-Controller Pattern.
And in the last there is a principle: In Model/Entity or in View/Boundary layers the components are independent on each other. All interdependence is in the Controller layer. So, the classic behaviour is the first one - when you create both Entity classes from controller.
But classes are not components. And on this abstraction level the rule is far from being so strict. For classes take it not as a rule, but as a nice target: try to keep your Entity classes being more independent on each other.
But if you have an Entity1 that is a composition of Entity2 class with something else, then the second variant is the only sensible one.

How to draw a relationship between a property and a class in ArgoUML?

In ArgoUML, I have the ability to put a class Type to any property of a class. For example, I can declare a customer property with a Customer type in the Order class.
I can also easily draw a relationship from class to class:
But I can't figure out how to "draw" the link from the customer property to the Customer class. The link is never really connected to the property, but rather to the entire Order class.
I can move the position of the link manually:
But it's never really "locked" to the customer property, and can be moved automatically by the software at any moment.
Is there a way to do this?
You can not have an association in UML which is not connecting the entire two classes. It is not possible to touch the property inside the class.
Workarounds are:
add a note linked to the property
add an icon to the property which would be designed like an association.
I don't know if this advanced icons customization is available in this free tool but it is in other tools.
I found a flash demo which shows the association attribute with an icon. Look at : http://www.download-omondo.com/show_association_member.swf
If you need to understand what mean an association in UML and code generation in Java then have a look at this demo: http://www.download-omondo.com/association.swf
Hope this help.
ArgoUML follows the UML specification. Associations are drawn from one class to another. Attributes are drawn inside the 2nd compartment of a class.
The association type closest in meaning to an attribute is composition, but they are not equivalent.
You should never portray something AND as an attribute of a class, AND as a separate class associated to it.
E.g. 1. an Order may have a Number, that may be used by the customer to identify his Order. The Number is best portrayed as an attribute (in the 2nd compartment of the class).
E.g. 2. an Order may be associated to the Customer who placed the order. The Customer is best portrayed as a separate class, since it has its own lifespan (behavior), associated with the Order. This allows to show multiplicities and roles at both ends of the association line.

Resources