Data Table Classes in UML Sequence Diagrams - uml

I've been struggling to understand the transition from a UML Class Design Diagram to a UML Sequence Diagram for a school assignment. My design class diagram contains a central DataManager class that connects the use case control classes to the data table classes (ie. user, product, employee), however, do I need to include the data table classes in my use cases' sequence diagrams?
Design Class Diagram
My Sequence Diagram Attempt

So, in the end, I didn't phrase my question as I wanted to. I was asking if communications between the database tables and the data manager class should also appear in the sequence diagram. The answer is, they should. The whole point of having a sequence diagram is to guide a developer in the "development" of a class. For my diagrams, all messages I used for this communication had a standard sql() operation for each message.

Related

Difference between the Domain Model & Activity Diagram

So I'm currently studying UML and I have a question regarding the difference between a Domain Model how this is compared with an Activity Diagram. I a bit confused with the following terms:
Activity Diagram (AD)
Domain Model (DM)
OO Domain Model (OO DM)
Class Diagram (as a term)
Domain Class Diagram (CD)
Design Class Diagram (DCD)
In Visual Paradigm, you have two the option between Activity & Class Diagrams to draw out your designs. So far I have been using Class Diagrams for my Domain Model but a friend of mine told me you should not be using Class Diagrams for your Domain Model. So my question what's the difference and how does a program like Visual Paradigm differentials with the standards of the subject I'm trying to learn.
Domain model and domain diagram do not exist in UML, so all depends on the definition you use.
If I look at the literature it seems the 'standard' diagram to show a domain model is a class diagram, may be associated with object diagram to show example of instances.
An activity is a behavior, to use common word an 'algorithm'. An activity can be used to model the body of an operation. The goal of an activity and a class are totally different, one cannot replace the other.
Even the definition in Wikipedia is a domain model is a conceptual model of the domain that incorporates both behaviour and data the associated diagram in the article is a class diagram. In the article the word behaviour visibly refer to the rules the business uses in relation to that data.
Anyway, whatever, all depends on what you have to model, there is no definitive rules saying in case 1 use only class diagram, in case 2 use only activity diagram, and so on. You use all the diagrams you want while they are adapted for to say something useful
Activity diagrams are used for represent the behavior which shows flow of control or object flow with emphasis on the sequence and conditions of the flow.
Example:
The class diagram is used to specify the relations that exist between the classes from your model, also you can represent their attributes and methods.
Example:
Going back to your question, if you want to represent the behavior of your model, I should recommend using an activity diagram, but if you only want to specify classes that you want to use and their relation then you can use a class diagram. 

Are all objects on sequence diagram should be designed in class diagram?

I'm working on sequence & class diagram for education website, should all objects in sequence diagram be a class in Class diagram?
For example in sequence diagram for registration process I need an object called "Data Base" which needed for saving information of user, should "Date base" be a class in class diagram? and what can be its functions? Is it just load & save?
I think it depends on the level of formality, abstraction, and the purpose of your UML model.
Martin Fowler talks about UML as Sketch, UML as Blueprint, and UML as Programming Language.
The terminology has gotten some good usage; and I think 'UML as Sketch' in particular has emerged as a popular mode, with the goal of human-to-human communication about the design of a system; not necessarily a formal engineering specification (i.e. a blueprint), nor suitable as an input to a code generator (i.e. a programming language).
If you want to use UML in Sketch mode, which is perfectly valid, then it's not a requirement for your sequence diagrams to use only the classes defined in your class diagram. In fact, some of the objects/lifelines in a sequence diagram aren't class instances at all:
They may be "actors" defined in a use case diagram (or not). Actors are often people, and as such are represented as stick figures. "End user" is a common actor to include in a sequence diagram. Plenty of examples here.
They may be external systems, like a database, that are not defined in your class model. Your system might have a class, or set of classes, to abstract the database, i.e. a "data access layer" or DAL. But then again, your system might not have a DAL; and even if it does, you might still want your sequence diagram to show the interactions across the boundary, between the DAL and the actual database.
Using UML as a sketch, the methods implemented by external actors or system components are really up to you. You could show a database query as execute query, or something more specific, like an actual SQL statement. The "correctness" of your diagram is in its ability to communicate effectively with your audience, at the right level of detail and formality.
Yes, the Database would be a class in Class Diagram and its functions can be validation() , generatingErrorMessage() etc.

Class diagram drawn from Use case description

I know that I can build a Class diagram from a database E-R Diagram (tables become classes, tables properties are the classes properties...)
But I'm looking for informations (or step by step like) to create a class diagram from a use case description (or even a sequence diagram).
(All I found now is that the sequence diagram objects becomes classes and the stimuli messages methodes)
Any idea ?
I used to TA in software engineering, and both create a class diagram from a textual definition as well as create a class diagram from a sequence diagram were regular exam questions.
Creating class diagrams from a specification should be covered in your lectures since its one of the most important things to learn. This site explains the workflow quite well in my opinion.
It is important to note, that in software engineering there never is just one solution. You can tackle problems in multiple ways each with their own benefits and problems. The most important step to learning is doing it yourself, just looking at solutions won't help you.
For creating class diagrams from a sequence diagram:
Objects are instance of classes, in most sequence diagrams there is only one instance of any given class. Therefore "objects become classes" is not technically correct but the right intention.
Messages represent method calls on the receiving object, ergo you need to add these methods to the class of the receiving object.
Any communicating classes need to be associated, else they could not call their methods.
We put focus on only modelling the information you can derive from the sequence diagram, e.g. in most cases you do not know multiplicities of associations.

When use use-case diagram and when use class diagram?

i'm php developer using MVC architecture that i'm new to UML
i know use-case , class , object , activity, sequence diagrams but i don't know for modeling a application where i should start.
i know use-case and class diagrams are structural diagrams and activity and sequence are behavior diagrams
but my questions are:
1. for modeling a app when i should use use-case diagram and when i should use class diagram?
2. does class diagram has abstract concept? because when i'm developing web app i have some controller and model or view also several classes that i use for different purpose (like insert data to database - validate form inputs and so on) but they don't look like to examples of class diagram that i'v seen until now so my question is class diagram is used for show concept of our system and it doesn't need to generate real class code form it ?
for example modeling a ticket reservation that may have some classes like this:
but we don't write class codes like this and it can be different in programming but for view the concept we are using class diagrams . is it true ?
Use-case diagram is usually used for representing the business of the project, indicate who(actor) are going to utilize the system and what services(cases) does program provide?
The class-diagram is used for specifying the whole system structure, but there no code and exact behavior will be provided by the class, generally developers don't specify the exact behavior with each module in-detail.
for example, consider a simple login module. in use-case diagram, we just mention that user logins into the system.
In class diagram we specify the possible base classes are needed, in other word we apply the architecture (we are planning) basis.
In sequence diagram we focus more on what is going on each method(while this is not necessary).
In fact UMl is used for representing the system as abstract, not the exact(in-detail) functionality.
for example I pass the above class-diagram to a developer, and tell him about the detail login process as a separated document.

How to represent a loop in a Class Diagram

I was wondering if anyone could explain to me how to represent a loop from UML sequence diagram in a Class Diagram.
Here's the Sequence Diagram:
and here's the Class Diagram I made from the Sequence Diagram
You don't.
Class diagrams are not about code execution; they are about the structure of your classes. In other words, your sequence diagram has a time component that shows the reader what happens during the execution. Class diagrams, on the other hand, are supposed to show class relationships (i.e. which class is associated/uses/derives from another class).
UML diagram taxonomy is divided into Behavoural and Structural diagrams. A class diagram is structural, you would need a behavioural diagram to describe loop semantics.
UML 2.x sequence diagrams have explicit notation for loops, while loop semantics may also be expressed in activity or state-machine diagrams.
In your sequence diagram, the loop is inside the :microndas::iniciar() method/message, and is therefore part of the description of that rather than the class diagram. You would attach a behavioural diagram to the :microndas class to describe this behaviour is necessary, though your existing sequence diagram may already suffice.
UML is about expressing different "views" or "aspects" of a system, It is wrong thinking to try to express all that is in one diagram type in another - if that were possible we'd only need one diagram type, and I do not want to go back to designing everything with a flow-chart; for one thing the stationary shop no longer sells those stencils!

Resources