It's possible to model the relation between attributes in associated class with the UML Designer? The objective is choose a source and the target class for describe one interaction between objects(for example describe a message in a sequence diagram) Something like this:
No it is not possible to represent dependencies in UML designer directly from attributes to attributes.
Related
I am trying to find a way of specifying how a given class attribute is persisted to an existing database model that I cannot modify at the moment. What i need to convey in a UML class diagram is how a class attribute is mapped to a given table column. Should I use stereotypes for this as illustrated below or is there a better way?
No, you should definitely not use stereotypes.
A stereotype denotes a meta-class that is an extension of a UML meta-class.
«table» is a commonly used stereotype used as an extension of the UML Class to indicate that this object is to be interpreted as a table rather then a generic Class.
Stereotypes can also define properties who will manifest in the model as tagged values. As such you could imagine a «column» stereotype that has a property mapping in which you can add a reference to the class attribute(s).
Some UML tools also have some sort of feature to link attributes to other attributes. UML doesn't really specify how this should be represented in a diagram, so the tools each have their own notation.
Enterprise Architect for example uses this notation:
(from the user manual)
Some classes in my class diagram need to reference specific instances of other classes or themselves. Should I just model those the same way i would in an object diagram or is there a better option? In general: Can one combine class and object diagrams, since object diagrams are themselves class diagrams?
thanks!
UML2 introduced Composite Structure Diagram exactly to solve this issue.
In a Composite Structure Diagram you can show classifiers (e.g. Classes) together with theirs internal composition in terms of instances.
This way you can specify exactly which instances are linked to your objects.
See this article for a good explanation.
I agree with #Thomas Killian : you want to mix two different representations.
On the class diagram you will be able to show cardinalities, but not instances relationships. It seems your List class is not a simple list but a chain / linked list.
A ListElement is in fact part of a LinkedList. Two predecessor and successor attributes themselves of type ListElement (or how you wish to call this class, the node role could be noted) will be enough to suggest the behavior. As an attribute has a 1:1 cardinality with the encapsulating class, this respects what you wish to model. Renaming the list class would be a hint for the diagram reader.
Take a look at the Java Linked List source if you want some ideas: this could help you to design a clear class structure, the initial author is not so bad at classes design. In this case, he pushes encapsulation to the excess but the idea is right.
On Wikipedia, I'm reading that an association relationship is an instance level relationship so we are talking about the relationship between the objects of two classes.
When we actually draw a class diagram, why do we use association on the class elements or blocks rather than objects? And there are also class level relationships for which we again use class elements. Since we don't have any way to show if we are talking about objects or classes I find this confusing. For example: I've heard people saying "Associate these two classes" Doesn't that sound wrong?
Links are to Associations as Objects are to Classes.
A Class is an abstraction that describes many specific objects. Similarly, an Association is an abstraction that describes many links between objects.
So your statement
an association relationship is an instance level relationship
isn't strictly correct because it mixes the abstraction (Association Relationship) with the instances it represents.
hth.
In fact, when you associate two or more classes it is done thanks to two or more UML Properties.
These latter are the "ends" of your associations and are "instance" i.e. they are typed by classe.
So an association is created between two classes on a class diagram but between each classes and the association you have a UML property.
Hoping it sounds clear ...
When you are making a class diagram you are defining types. Suppose you have a class User and a class Account, you use an association between User and Account to say: User instances can have link(s) with Account instances at runtime.
So, you use classes and associations at type level (class diagram) to define what can be possible at runtime (instance level).
The object is actually the Class that has been created virtualy. So a class is the "static" version of an Object. So, when we speak of UML, we speak about classes and not object.
But correct me if I'm wrong!
Can I improve my design on these 2 diagrams below? If so, how?
I am confused by the use of association classes in my diagrams. Should I use them?
Figure 1
Figure 2
For association classes, they make sense only if they represent associations with some behaviour and state. Look at Article'sSubject. It has nothing more than source, target and identity. You don't need a class for such a association, just use plain association, which has all those properties. There are more such unnecessary association classes in your diagrams. Another important thing when using association classes is that every instance of that association class should have unique source and target pair. For example Comment is not identifiable just by Article and User - one user may have man ycomments on one article and that is not allowed.
An association class is used to capture certain characteristics of an association between two classes. These characteristics do not belong to the classes being associated but instead belong to the relationship between the classes.
What kind of UML diagram is this?
(source: tripod.com)
This is a class diagram, with added stereotypes
This is Class Diagram in a very abstract or initial form because all relationship are shown as Association.
Usually we start with such class diagram and then keep on refining by converting association (arrow as shown above) into more stronger relationship like generalization,composition,implementation etc.
Association is considered as weaker form of relationship between classes. So final class diagram should have fewer associations.
What is the emphasis or goal of this diagram? If it's the classes and relationships, then it's a class diagram. If it's the mapping between the classes and layers of function or responsiblity in the system, then it looks like a layer diagram. Those columns look like layers: presentation, business logic, data...
Ok now I see the problem after a good sleep :-)
It seems it is a powerpoint and not a class diagram because you can not have straight line in a class diagram. I mean you can not have 3 separators like Presentation/ objectos .......etc
This powerpoint tried to use class diagram and have added titles in order to separate 3 layers. The problem is that the class diagram is incorrect and it is not because you present it with 3 layer that it would become correct !! This is a bad understanding of what means JPA stereotypes inside a class diagram.
It looks like a Class Diagram that uses "swimlanes" on the background to facilitate some kind of MVC.
This class diagram is not correct because there is confusion between Java EE stereotypes and class names!
What are the << class module>> , << module>> stereotypes and Session, Session persistence names should be Java EE stereotypes. If it persists in the database then it is an entity! Persistence etc...can be written on attributes.
This diagram doesn't make sense!
The main advantage of scheme in this diagram is that if you use a code generator such as AndroMDA, MIA software or Blue Age, then you can then generate your database directly from the model. These tools look at stereotypes during code generation.
If you don't want to generate code from a model but prefer to let hibernate mapping do the job, then the "entity" stereotype can be written as an annotation in your java code. Then thanks to live code and model synchronization, hibernate can take the annotation and produce a mapping.
This is why stereotyping is really very important and using the wrong stereotype can be a very serious mistake!