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

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.

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.

Class diagram from use case, should I include the system?

I am trying to build a class diagram from use case. But I am not sure if I should include the system in class diagram. I have system as actor in use case diagram. If I include it in the case diagram can I use it without attributes....
"I have system as actor in use case diagram" - Actor can be human or non-human system external to your subject that is your whole system. For example, card payment system or buyer are actors for net stores. You can show your system in the use case diagram, too, but it will be a rectangle, containing ALL use cases - not really so much useful thing. But showing of SUBsystems can be useful.
Later you can draw a deployment diagram - if different subsystem lie on different computers. And maybe, some dynamic diagrams of how they talk to each other and actors.
If we are talking on static diagrams, your next step will be component diagram - you'll divide your system in smaller parts and show who talks to who and here already the classes of messages being sent can appear.
Later - you'll plan what packages will contain your classes and what will be visible from which. Package diagram.
Later - yes, at last we are here - you create the class diagram(s). Maybe, several - for different components. So, you are a bit too in a hurry.
Sometimes, especially, if you work with some special objects of some class(es), you need Object Diagram.
And don't forget - there are also dynamic diagrams, I have mentioned static ones only.
Can you please elaborate your question with specific example in order to get better knowledge about the scenario?
As far my knowledge, one can use the system such as any controller class which is again an actor here as class in the class diagram.
"I am trying to build a class diagram from use case"
Use-cases are a very abstract and user-centric view of the system while class diagrams are fine-grained and technically focused.
So you should not try to infer your classes directly from a UC diagram. Instead, use the repertoire UML gives you (component-, activity-, sequence diagrams etc.)
In my experience, I usually create Object interaction Diagram from Use Cases. Mostly, the nouns on the Use Cases are Classes ... In Object Interaction Diagrams, I can have clear ideas about the methods and lifespan of the Classes ...
"Object Interaction Diagrams" or "Interaction Diagrams" are usually to elaborate a single use Case ..
A simple google search gave me this link and it gives you some idea ...
http://www.cs.unc.edu/~stotts/145/CRC/Interactions.html

Which diagram I should change in UML?

Can anyone tell which UML diagram I should change if there is a slight change in the design of application.
The change is -> Earlier the application was using Active directory for authentication now I want to use the Membership provider instead.
I want to keep the change minimum in diagrams.
Thanks
Sounds like component diagrams or class diagrams. Check out the following topics and illustrations for VS 2010 Ultimate RC:
UML Component Diagrams: Reference at http://msdn.microsoft.com/en-us/library/dd409390%28VS.100%29.aspx:
A component diagram shows the parts of a design for a software system. A component diagram helps you
visualize the high-level structure of the system and the service behavior that those pieces provide
and consume through interfaces.
UML Class Diagrams: Reference at http://msdn.microsoft.com/en-us/library/dd409437%28VS.100%29.aspx
A UML class diagram describes the object and information structures used by your application, both
internally and in communication with its users. It describes the information without reference to any
particular implementation.
It will surely depend the diagrams at your disposal. Sound like a correction in one of the static diagram types, like the component diagram ...
This of course depends on how you structure your documents and your uml-diagrams.
In general I have a Conceptual model, Class Diagram and a Design Diagram which are diractly linked to the architecture. And then you should in most cases have System Sequence Diagrams and more. However, depending on how your structure is and to minimize the "changes" required.
I would suggest that you use something more generic for the parts that might be changed. Active Directory Authentication and Membership Provider Authentication is both Authentication methods, which means that you can, instead of displaying the whole sequence at the Authentication step, just use "Authentication".
Now, in the conceptual models and in the design + class diagrams, you will need to change and add some fields, tables or whatever is added. But it shouldn't matter if you need to add more or less, because the documents need to reflect upon your software as accurate as possible.
So, to minimize changes, use more generic types.

Resources