Uml PDF
Uml PDF
- UML – Unified Modeling Language diagram is designed to let developers and customers view a software
system from a different perspective and in varying degrees of abstraction.
why UML
- It provides a standard visual language for modeling system, helping to simplify complexities
1
Structural Diagrams
- Structure diagrams emphasize on the things that must be present in the system being modeled.
- Since structure diagrams represent the structure, they are used extensively in documenting the software
architecture of software systems.
Behavioural Diagrams
- Behavior diagrams emphasize on what must happen in the system being modeled.
- Since behavior diagrams illustrate the behavior of a system, they are used extensively to describe
the functionality of software systems.
2
Use Case Diagram
-----------------------------------------------------------------------------------------------------------------------------
Introduction:
- A use case diagram describes how a system interacts with outside actors.(among elements and system)
- Each use case representation a piece of functionality that a system provides to its user.
- Use case identifies the functionality of a system.
- Use case diagram allows for the specification of higher level user goals that the system must carry out..
- A use case diagram at its simplest is a representation of a user's interaction with the system and
depicting the specifications of a use case.
- A use case diagram contains four components.
i. The boundary, which defines the system of interest in relation to the world around it.
ii. The actors, usually individuals involved with the system defined according to their roles.
iii. The use cases, which the specific roles are played by the actors within and around the system.
iv. The relationships between and among the actors and the use cases.
Purpose:
- The main purpose of the use case diagram is to capture the dynamic aspect of a system.
- Use case diagram shows, what software is suppose to do from user point of view.
- It describes the behavior, major processes and scope of system from user’s point.
3
Use Case Notations
No. Name Notation Description
2 Use case A use case represents a user goal that can be achieved by
accessing the system or software application.
4 Association Actor and use case can be associated to indicate that the
actor participates in that use case. Therefore, an
association corresponds to a sequence of actions
between the actor and use case in achieving the use
case.
4
7 Extends An extend relationship specifies how the behavior of
the extension use case can be inserted into the
behavior defined for the base use case.
5
UML Diagrams
Examples:
10
UML Diagrams
Class Diagram
-----------------------------------------------------------------------------------------------------------------------------
Introduction
- The class diagram is a static diagram.
- A class model captures the static structure of a system by characterizing the objects in the system,
the relationship between the objects, and the attributes and operations for each class of objects.
Purpose
- Analysis and design of the static view of an application.
- Describe responsibilities of a system.
- Base for component and deployment diagrams.
11
UML Diagrams
12
UML Diagrams
13
UML Diagrams
14
UML Diagrams
Examples:
15
UML Diagrams
16
UML Diagrams
17
UML Diagrams
18
UML Diagrams
19
UML Diagrams
1 Prepare Class diagram showing at least 10 relationships among the following object classes. Include associations
and qualified associations, aggregations, generalizations, and multiplicity. You may add additional objects. Also
show attributes and operations. School, playground, principal, school board, classroom, book, student, teacher,
canteen, restroom, computer, desk, chair.
20
UML Diagrams
2 Prepare a class diagram for each group of classes. Add at least 10 relationships (associations and generalizations)
to each diagram. File system, file, ASCII file, binary file, directory file, disc, drive, track, and sector.
21
UML Diagrams
3 Prepare a class diagram for group of classes. Sink, freezer, refrigerator, table, light, switch, window, smoke
alarm, burglar alarm, cabinet, bread, cheese, ice, door, kitchen
4 Prepare a class diagram for the dining philosopher problem. There are 5 philosophers and 5 forks around a
circular table. Each philosopher has access to 2 forks, one on either side. Each fork is shared by 2
philosophers. Each fork may be either on the table or in use by one philosopher. A philosopher must have 2
forks to eat.
22
UML Diagrams
5 Categorize the following relationships into generalization, aggregation or association. Justify your answer.
i. A country has a capital city.
Association. A capital city and a country are distinct things so generalization certainly does not apply. You
could argue that a capital city is a part of a country and thus they are related by aggregation.
ii. A file is an ordinary file or a directory file.
Generalization. The word “or” often is an indicator of generalization. File is the super class and Ordinary File
and Directory File are subclasses.
iii. Files contain records.
Aggregation. The word “contain” is a clue that the relationship may be aggregation. A record is a part of a
file. Some attributes and operations on files propagate to their constituent records.
iv. A polygon is composed of an ordered set of points.
Aggregation or Composition. The phrase “is composed of” should immediately make you suspicious that
there is an aggregation. An ordered set of points is a part of a polygon. Some attributes and operations on a
polygon propagate to the corresponding set of points.
v. A drawing object is text, a geometrical object, or a group.
Generalization. Once again, the word “or” should prompt you to think of generalization. DrawingObject is
the super class. Text, Geometrical Object, and Group are subclasses.
vi. A route connects two cities.
Association. Either Route is a class associated with the City class, or Route is the name of the association
from City to City.
vii. A student takes a course from a professor.
Ternary association. Student, Course, and Professor are distinct classes of equal stature.
viii. A person uses a computer language on a project.
Ternary association. Person, Computer Language, and Project are all classes of equal stature. The association
cannot be reduced to binary associations. None of these classes are a-kind-of or a-part-of another class.
Thus generalization and aggregation do not apply.
ix. Modems and keyboards are input / output devices.
Generalization. The keyword “are” is the clue. Modem and Keyboard are the subclasses; InputOutputDevice
is the super class.
x. Classes may have several attributes.
Association or aggregation. It depends on your perspective and the purpose of the model whether
aggregation applies.
23
UML Diagrams
5 Prepare a class diagram for a graphical document editor that supports grouping. Assume that a document
consists of several sheets. Each sheet contains drawing objects, including text, geometrical objects and groups. A
group is simply a set of drawing objects, possibly including other groups. A group must contain at least two
drawing objects. A drawing object can be a direct member of at most one group. Geometrical objects include
circles, ellipses, rectangles, lines and squares.
6 Prepare a meta-model that supports only the following UML concepts: class, attribute, association, association
end, multiplicity, class name, and attribute name. Use only these constructs to build meta-model.
24
UML Diagrams
State Diagram
-----------------------------------------------------------------------------------------------------------------------------
Introduction
- A state diagram is a graph in which nodes correspond to states and directed arcs correspond to transitions
labeled with event names.
- A state diagram combines states and events in the form of a network to model all possible object states
during its life cycle, helping to visualize how an object responds to different stimuli.
- A state diagram is a graph whose nodes are states and whose directed arcs are transitions between states.
- A state diagram specifies the state sequence caused by event sequence.
- State names must be unique within the scope of a state diagram.
- All objects in a class execute the state diagram for that class, which models their common behavior.
- We can implement state diagrams by direct interpretation or by converting the semantics into equivalent
programming code.
Purpose
- The state model describes those aspects of objects concerned with time and the sequencing of operations
events that mark changes, states that define the context for events, and the organization of events
and states.
- They are used to give an abstract description of the behavior of a system.
- It provides direction and guidance to the individual counties w i t h i n t h e states.
- It specifies the possible states, what transitions are allowed between states.
- It describes the common behavior for the objects in a class and each object changes its
behavior from one state to another.
- It is u s e d to describe the dependence o f the functionality o n the state of the system
that is how the functionality o f an object depends on its state and how its state changes as a
result of the events that it receives.
- It describes dynamic behavior of the objects of the system.
When to use: State Diagram
- They are perfectly useful to model behavior in real time system.
- Each state represents a named condition during the life of an object during which it
satisfies some condition or waits for some event.
- It determines how objects of that class react to events.
- For each object state, it determines what actions the object will perform when it receives an event.
25
UML Diagrams
26
UML Diagrams
27
UML Diagrams
Examples:
State diagram for library management system
28
UML Diagrams
29
UML Diagrams
30
UML Diagrams
31
UML Diagrams
32
UML Diagrams
33
UML Diagrams
34
UML Diagrams
35
UML Diagrams
36
UML Diagrams
37
UML Diagrams
38
UML Diagrams
39
UML Diagrams
40
UML Diagrams
41
UML Diagrams
Sequence Diagram
-----------------------------------------------------------------------------------------------------------------------------
Introduction
- Sequence diagrams model the dynamic aspects of a software system.
- The emphasis is on the “sequence” of messages rather than relationship between objects.
- A sequence diagram maps the flow of logic or flow of control within a usage scenario into a visual diagram
enabling the software architect to both document and validate the logic during the analysis and design
stages.
- Sequence diagrams provide more detail and show the message exchanged among a set of objects over time.
- Sequence diagrams are good for showing the behavior sequences seen by users of a diagram shows only
the sequence of messages not their exact timing.
- Sequence diagrams can show concurrent signals.
Purpose
- The main purpose of this diagram is to represent how different business objects interact.
- A sequence diagram shows object interactions arranged in time sequence.
- It depicts the objects and classes involved in the scenario and the sequence of messages
exchanged between the objects needed to carry out the functionality of the scenario.
- Sequence diagram can be a helpful modeling tool when the dynamic behavior of objects needs to be
observed in a particular use case or when there is a need for visualizing the “big picture of message flow”.
- A company’s technical staff could utilize sequence diagrams in order to document the behavior of a
future system.
- It is during the design period that developers and architects utilize the diagram to showcase the
system’s object interactions, thereby putting out a more fleshed out overall system design.
42
UML Diagrams
43
UML Diagrams
44
UML Diagrams
Examples:
Issue book
45
UML Diagrams
Return book
46
UML Diagrams
:customer :Server
Log-
in
Display banks detail
Select bank
Display form
Fill Form
Submit form
47
UML Diagrams
Transaction
Log in
Open account
Select transection
type
e
y
Enter detail ( Mon ) Display transection
form Submit
form {Verify
Counting balance Modify
Give money database}
Request for
recipt
Give recipt
Log out
48
UML Diagrams
Exceptional case
49
UML Diagrams
Supply order
50
UML Diagrams
Product Exchange
51
UML Diagrams
52
UML Diagrams
53
UML Diagrams
54
UML Diagrams
Prepare food
Supply food
55
UML Diagrams
Activity Diagram
-----------------------------------------------------------------------------------------------------------------------------
Introduction
- An activity diagram is a type of flow chart with additional support for parallel behavior.
- This diagram explains overall flow of control.
- Activity diagram is another important diagram in UML to describe dynamic aspects of the system.
- Activity diagram is basically a flow chart to represent the flow from one activity to another activity
- The activity can be described as an operation of the system.
- The control flow is drawn from one operation to another. This flow can be sequential, branched or
concurrent. This distinction is important for a distributed system.
- Activity diagrams deals with all type of flow control by using different elements like fork, join etc.
Purpose
- Contrary to use case diagrams, in activity diagrams it is obvious whether actors can perform business use
cases together or independently from one another.
- Activity diagrams allow you to think functionally.
56
UML Diagrams
57
UML Diagrams
Examples
58
UML Diagrams
59
UML Diagrams
60
UML Diagrams
Transaction
61
UML Diagrams
62
UML Diagrams
Payment
63
UML Diagrams
64
UML Diagrams
Server Operation
65
UML Diagrams
66
UML Diagrams
1. Prepare an activity diagram for computing a restaurant bill. There should be a charge for each delivered item.
The total amount should be subject to tax and a service charge of 18% for groups of six of more. For smaller
groups, there should be a blank entry for a gratuity according to the customer’s discretion. Any coupons or
gift certificates submitted by the customer should be subtracted.
67