How to represent repository pattern in UML? - uml

How to represent Repository pattern in UML?
Is there any stereotype that can be used to describe repository pattern? I am using Enterprise Architect to create diagrams. I specifically looking for class diagram representation.

According to Martin Fowler, P of EAA, p. 322:
(However, you must have already found this since it's the first hit on Google.)
Based on this example (and the text from P of EAA), this roughly translates to the following DCD:

jensgram has already provided an answer on how to represent the pattern as classes.
When it comes to using patterns in EA, you can quite easily create them yourself using Save UML Pattern under the Diagram - Advanced menu. This saves an XML representation of the pattern.
You import the pattern for use in your project either using the Resources window or by creating an MDG Technology (more complex, but a much better alternative for medium and large-scale deployments).
Unfortunately, the one UML diagram type where EA does not support pattern creation is the sequence diagram.

Related

UML Integrated Class Diagram

What is an integrated class diagram? what is the difference between a class diagram and an integrated class diagram? I have searched on google and youtube but could not find a proper explanation.
There is no notion of "integrated class diagram" defined in the UML specifications, and it's not a popular term if you search in specialized publications.
Unless you are learning a custom modelling technique inspired from UML, the term "integrated" shall therefore be taken in its usual system engineering sense: assembling parts together to make a working whole.
Applied to a class diagram, this would mean to either consolidate several models into a single one (e.g. for the purpose of integrating sub-systems), or assembling model parts (e.g. if you have separate class diagrams each focusing on specific parts of a system, and then want to show the big picture and how these groups of classes relate to each other).

Regarding UML diagrams and patterns?

I have a general UML question. I am studying a course in programming and the theme is pattern. So I would like to know if UML is connected somehow with patterns?
Yes. And no. You will likely see all design patterns drawn as diagrams. For example, the GOF (which is the reference book on the topic) does not use regular UML (because it was first published in 1995) but a representation very similar to class diagrams.
This is because you can draw the blueprint (which the class diagram represents) very easily with UML. You can then use that blueprint directly for your design and transform it to any code you want.

code path on UML class diagrams

I usually document system architectures with traditional UML class diagrams, and then further document the most important/complex code paths with arrows from one method to another, and which property it updates, etc. Usually with little notes of the arguments used and values set.
something like (horrible ascii art warning)
--------------
CASE X | main class | -----------------
-------------- | util |
| count |<-+1 -----------------
-------------- | -----------------
user ---x=A-->| doStuff(x) | ---y=Z---<>| someMath(x,y) |
| other() | -----------------
--------------
is there a name for such a thing? note how i'm pointing to individual methods/properties, not to whole classes as a traditional UML diagram would.
I use graphviz/dot for all my other graphs. but i can easily move to something else that allows me to do that... i just rather it be programatical like graphviz, not a drawing tool like visio if possible.
Please, feel free to edit to add tags if you think some other graph engine may provide this.
No, there is no name for such thing in the UML world. Although in UML you can draw diagrams combining various drawing elements nearly at will and thus producing a new inventions it, your drawing does not fall into the UML standard.
A very big advantage of using standard is that other people can understand what you mean without the need to provide them some reading instructions.
In UML there is whole set of "traditional UML diagrams" categorized as "Behavior Diagram". You may want to go through the examples in Kirill Fakhroutdinov's online book http://www.uml-diagrams.org/index-examples.html
UML Sequence Diagram (in your case) seems to be the first thing to play with.
In UML using drawing tools to produce some picture may be the poor-man's choice, but you'd have to study hard to make sure that you put the picture right.
Instead of using a picture drawing tools, we rather use UML Modeling tools which support the drawing-right and they sort of "know" what the picture shows and can generate code from the UML model (e.g. hierarchical state machines) or can reverse engineer a source code into an UML model.
Furthermore the UML model format was standardized as XML Metadata Interchange (*.XMI) and once you have model in this format you can use various tools to round-trip and produce artifacts (generated documentation, generated code, ...) that you need
As xmojmr has said, you ought to look at sequence diagrams. UML breaks itself into structural and behavioral diagrams. You probably shouldn't add behavioral elements into a structural diagram (which is what you are doing). Your explanation of why you are doing what you are doing is exactly the sort of explanation that people give for the use of sequence diagrams: they're a way of documenting paths through your code.
You'll also find that they are used to document paths through use cases (a "use case scenario" is a path through a use case), so keep in mind that class diagrams represent the structure of use cases. In other words, they all go together, but you're likely to see a lot of sequence diagrams that have been worked out from use cases rather than class diagrams. I wanted to point this out so you don't get confused by the apparent orientation of sequence diagrams and use case diagrams.

Does generalization exist in UML Use Case Diagrams?

I'm trying to model some requirements and I saw some examples in the web with use cases generalization, but the UML 2.5 standard review doesn't say anything about generalization in Use Case Diagrams, or I can't find it.
So, is generalization supported by standards?
Since a UseCase is a Classifier, they can be generalized. The UML 2.5 spec contains an example of this in Fig. 18.11 on p. 686 (the "ATM Services" example).
Tricky.
While the Generalization relationship is defined as going between two Classifiers, and a Use Case is itself a specialization of a Classifier, the semantics of the Generalization relationship are primarily focused on Features (eg Attributes). These are inherited, but relationships are not.
On the other hand, the UML specification itself includes an example of use case generalization (2.4.1 Superstructure, fig 16.7, p 609).
Back on the first hand, the same specification omits generalization in table 16.1, "Graphic nodes included in use case diagrams" (p 611-613), but does include the two main intra-use case relationships; Extend and Include.
On the other hand again, the same table includes Actor but excludes the Association between Actor and Use Case.
Sadly, the UML specification is in many respects a horrifying mess, and the 2.5 version is in part an attempt to rectify this.
On balance, I would say no - you can't generalize between use cases.
I don't know if use case generalization is "supported" by an official UML standard. But
it is supported by Kirill Fakhroutdinov's online book (a site that I personally use as "standard" reference) at http://www.uml-diagrams.org/use-case.html#abstract-use-case
it is supported by the Agile Modeling online book at http://www.agilemodeling.com/essays/useCaseReuse.htm#InheritanceUC
it is supported by the Sparx Systems Enterprise Architect tool
it is supported by the Modelio the open source modeling environment tool
So my conclusion is that use case generalization is supported just enough and practically you can use if you need it.
But more usual way to express that one use case is specialization of another use case is (IMO) through the <<extend>> relationship. See http://www.uml-diagrams.org/use-case-extend.html and http://www.batimes.com/articles/use-case-goals-scenarios-and-flows.html (and Wikipedia) for some more detailed discussion
As gwag has mentioned, generalization/specialization is indeed included in the use case spec. What's more, there are plenty of situations where it is useful. Here's an example, from this page:

UML data relationship tool

I'm learning software engineering at school and right now we're focusing on data diagrams. That is, Objec Classes, associations (and multiplicities), Ternary (or in general N-ary) assocciations, aggregation classes and so on.
I've been taught that we are using the UML standard, but as far as I can see, most UML editors I've found don't even support (or do it very poorly) the UML concepts I am using, I find myself using text labels all over the diagram to express almost anything, and I can't even define an N-ary association properly. I can draw a diamond from the flow-chart drawing part and draw some arrows, then define multiplicities with labels, but I find that unprofessional.
So, I've got two questions: Is UML what I've been taught? Does it have a more specific name (I was told they were called data diagrams).
How can I check that I am using the correct tool and that it is really UML what I study?
n-ary associations are UML. But they are not so often used really. Most of associations are one-or two-directional binary ones.
DATA diagrams are NOT UML. But the standard allows to use class diagrams for showing tables and their relationships. If you use class diagrams, it is UML, if data diagrams, it is not.
Multiplicities are UML. You should define them as attributes of association.
As for arrows, UML standard allows not to show them. But of course, they should be again set as attributes of association.
It seems that you use diagramming tool without UML class diagrams support. And youu need rather a modelling tool. Try VP-UML - it has free community license, including all types of UML diagrams. Or if you can install Eclipse, it has many UML plugins. The largest are EMF or Papyrus. They are free. Green UML is for starters.
I understand your troubles - many "UML" courses do not teach real UML. Many widely used tools have errors in UML realization. Some of them (IBM) are very far from the standard. The best place to check if you are on the right way, is the OMG UML 2.5 standard. It is beta2, but the content is virtually equal to the current 2.4.1, and is more easy to understand. (the current change has merely to simplify the documentation)

Resources