Sie sind auf Seite 1von 54

UNIFIED MODELING

LANGUAGE (UML)
Unified Modeling Language
 a standard language for specifying, visualizing,
constructing, and documenting the artifacts of
software systems, as well as for business modeling
 a mostly graphical modeling language that is used
to express designs
 describes a notation and not a process
 helps project teams communicate, explore potential
designs, and validate the architectural design of the
software
Goals of UML
 Provide users with a ready-to-use, expressive visual
modeling language so they can develop and
exchange meaningful models.
 Provide extensibility and specialization mechanisms
to extend the core concepts.
 Be independent of particular programming
languages and development processes.
Goals of UML …cont.
 Provide a formal basis for understanding the
modeling language.
 Encourage the growth of the OO tools market.
 Support higher-level development concepts such as
collaborations, frameworks, patterns and
components.
 Integrate best practices.
Why use UML?
 to improve the quality of software products and
reduce cost and time-to-market
 To effectively manage the complexity of systems as
they increase in scope and scale
 the need to solve recurring architectural problems, such
as physical distribution, concurrency, replication,
security, load balancing and fault tolerance
Types of UML Diagrams
 Use Case Diagrams
 Class Diagrams
 Interaction Diagrams
 Sequence & Collaboration Diagrams
 State Diagram
 Activity Diagram
 Physical Diagrams
 Component & Deployment Diagrams
Use Case Diagrams
A use case diagram displays the relationship
among actors and use cases.
Use Case Diagram
 A use case is a set of scenarios that describing an
interaction between a user and a system.
 Use case diagrams describe what a system does
from the standpoint of an external observer.
 The emphasis is on what a system does rather than
how.
 The two main components of a use case diagram
are use cases and actors.
Actors & Use Cases
 An actor is represents a user or another system that
will interact with the system you are modeling.
 A use case is an external view of the system that
represents some action the user might perform in
order to complete a task.
 Use case diagrams are closely connected to
scenarios.
 A scenario is an example of what happens when
someone interacts with the system.
The Scenario
 "A patient calls the clinic to make an appointment
for a yearly checkup. The receptionist finds the
nearest empty time slot in the appointment book
and schedules the appointment for that time slot. "
The Use Case Diagram
When to use diagram?
 helpful in exposing requirements and planning the
project.
 Use case diagrams are helpful in three areas.
 determining features (requirements). New use cases often
generate new requirements as the system is analyzed and
the design takes shape.
 communicating with clients. Their notational simplicity
makes use case diagrams a good way for developers to
communicate with clients.
 generating test cases. The collection of scenarios for a use
case may suggest a suite of test cases for those scenarios.
How to draw Use Case Diagram?
 Start by listing a sequence of steps a user might
take in order to complete an action.
 For example a user placing an order with a sales
company might follow these steps.
 Browse catalog and select items.
 Call sales representative.

 Supply shipping information.

 Supply payment information.

 Receive conformation number from salesperson.


The Diagram
Class Diagrams
Class diagrams model class structure and contents
using design elements such as classes, packages
and objects.
Class diagrams describe three different
perspectives when designing a system, conceptual,
specification, and implementation.
Class Diagram
 gives an overview of a system by showing its classes
and the relationships among them.
 Class diagrams are static -- they display what
interacts but not what happens when they do
interact.
 Classes are composed of three things: a name,
attributes, and operations.
An Example of a Class
 Class diagrams also display relationships such as
containment, inheritance, associations and others.
Relationships in Class Diagrams
 Association
 shows the relationship between instances of classes
 theclass Order is associated with the class Customer (refer
to previous example)
 denotes the number (multiplicity of the association) of
objects that can participate in the relationship
 anOrder object can be associated to only one customer, but
a customer can be associated to many orders (refer to
previous example)
 an association is a link connecting two classes.
Multiplicity of an Association

Multiplicities Meaning
zero or one instance. The notation n . .
0..1
m indicates n to m instances.
no limit on the number of instances
0..* or *
(including none).
1 exactly one instance
1..* at least one instance
Relationships in Class Diagrams
 Generalization
 used when two classes are similar, but have some
differences.
 has a triangle pointing to
the superclass
Relationships in Class Diagrams
 Aggregation
 an association in which one class belongs to a collection.
 An aggregation has a diamond end pointing to the
part containing the whole.
 In our diagram, Order has a collection of OrderDetails.
How to draw Class Diagrams?
 consider the three different perspectives of the
system the diagram will present; conceptual,
specification, and implementation.
 When designing classes consider what attributes
and operations it will have.
 Then try to determine how instances of the classes
will interact with each other.
The Class Diagram
A Customer Ordering System
Interaction Diagrams
Interaction diagrams model the behavior of use
cases by describing the way groups of objects
interact to complete the task.
The two kinds of interaction diagrams are
sequence and collaboration diagrams.
Sequence Diagrams
 an interaction diagram that details how operations
are carried out -- what messages are sent and
when.
 organized according to time.
 The time progresses as you go down the page.
 The objects involved in the operation are listed from
left to right according to when they take part in the
message sequence.
Hotel Reservation
Explanation
 The Reservation window sends a
makeReservation() message to a HotelChain.
 The HotelChain then sends a makeReservation()
message to a Hotel.
 If the Hotel has available rooms, then it makes a
Reservation and a Confirmation.
Explanation
 Each vertical dotted line is a lifeline, representing
the time that an object exists.
 Each arrow is a message call.
 An arrow goes from the sender to the top of the
activation bar of the message on the receiver's
lifeline.
 The activation bar represents the duration of
execution of the message.
Explanation
 In our diagram, the Hotel issues a self call to
determine if a room is available.
 If so, then the Hotel creates a Reservation and a
Confirmation.
 The asterisk on the self call means iteration (to
make sure there is available room for each day of
the stay in the hotel).
 The expression in square brackets, [ ], is a
condition.
Collaboration Diagrams
 are also interaction diagrams
 They convey the same information as sequence
diagrams, but they focus on object roles instead of
the times that messages are sent.
 In a sequence diagram, object roles are the vertices
and messages are the connecting links.
Hotel Reservation System
Collaboration Diagram Notations
 The object-role rectangles are labeled with either
class or object names (or both).
 Class names are preceded by colons ( : ).
 Each message in a collaboration diagram has a
sequence number.
 The top-level message is numbered 1. Messages at
the same level (sent during the same call) have the
same decimal prefix but suffixes of 1, 2, etc.
according to when they occur.
When to use Interaction Diagrams?
 used when you want to model the behavior of
several objects in a use case.
 They demonstrate how the objects collaborate for
the behavior.
 Interaction diagrams do not give a in depth
representation of the behavior.
 If you want to see what a specific object is doing
for several use cases use a state diagram.
How to draw Sequence Diagrams?
 A class start the behavior by sending a message to
an object of another class.
 Messages pass between the different objects until
the object of the first class receives the final
message.
How to draw Collaboration
Diagrams?
 objects are listed as icons and arrows indicate the
messages being passed between them.
 The numbers next to the messages are called
sequence numbers.
 As the name suggests, they show the sequence of
the messages as they are passed between the
objects.
A simple 1, 2, 3... format can be used, as the example
below shows, or for more detailed and complex
diagrams a 1, 1.1 ,1.2, 1.2.1... scheme can be used.
Illustration
State Diagrams
State diagrams are used to describe the behavior
of a system. State diagrams describe all of the
possible states of an object as events occur. Each
diagram usually represents objects of a single
class and tracks the different states of its objects
through the system.
State Diagrams
 Objects have behaviors and state.
 The state of an object depends on its current
activity or condition.
 A state diagram shows the possible states of the
object and the transitions that cause a change in
state.
When to use State Diagrams?
 to demonstrate the behavior of an object through
many use cases of the system
 use state diagrams for classes where it is necessary to
understand the behavior of the object through the
entire system.
 Not all classes will require a state diagram and state
diagrams are not useful for describing the collaboration of
all objects in a use case.
 Usually combined with other diagrams such as interaction
diagrams and activity diagrams.
How to Draw State Diagrams?
 Basic Elements:
 rounded boxes representing the state of the object
 arrows indicting the transition to the next state.

 The activity section of the state symbol depicts what


activities the object will be doing while it is in that
state.
How to Draw State Diagrams?
 States - rounded rectangles
 Arrows - transition from one state
to another
 Events or conditions that trigger
transitions are written beside the
arrows.
 The action that occurs as a result
of an event or condition is
expressed in the [form/action].
 The initial state (circle) is a dummy
to start the action.
How to Draw State Diagrams?
 All state diagrams have an initial state of the
object.
 This is the state of the object when it is created.
 After the initial state the object begins changing
states.
 Conditions based on the activities can determine
what the next state the object transitions to.
Simple Order Dispatching System
Explanation
 When the object enters the Checking state it
performs the activity "check items."
 After the activity is completed the object transitions
to the next state based on the conditions [all items
available] or [an item is not available].
 If an item is not available the order is canceled. If all
items are available then the order is dispatched.
 When the object transitions to the Dispatching state
the activity "initiate delivery" is performed.
 After this activity is complete the object transitions
again to the Delivered state.
Example: ATM Transaction
Activity Diagrams
Activity diagrams describe the workflow behavior
of a system. Activity diagrams are similar to state
diagrams because activities are the state of doing
something. State diagrams describe the state of
activities by showing the sequence of activities
performed. Activity diagrams can show activities
that are conditional or parallel.
Activity Diagrams
 a fancy flowchart.
 While a state chart diagram focuses attention on an
object undergoing a process (or on a process as an
object), an activity diagram focuses on the flow of
activities involved in a single process.
 The activity diagram shows the how those activities
depend on one another.
How to Draw: Activity Diagrams
 Diagrams are read from top to bottom and have
branches and forks to describe conditions and parallel
activities.
 A fork is used when multiple activities are occurring at the same
time.
 The branch describes what activities will take place based on a
set of conditions. All branches at some point are followed by a
merge to indicate the end of the conditional behavior started by
that branch.
 After the merge all of the parallel activities must be
combined by a join before transitioning into the final
activity state.
Illustration
Order Processing System
ATM Withdrawal
When to Use: Activity Diagrams
 should be used in conjunction with other modeling
techniques such as interaction diagrams and state
diagrams
 The main reason to use activity diagrams is to model
the workflow behind the system being designed.
 Activity Diagrams are also useful for:
 analyzing a use case by describing what actions need
to take place and when they should occur;
 describing a complicated sequential algorithm; and

 modeling applications with parallel processes.


End of Lecture
Unified Modeling Language

Mr. Albert H. Subang


Professor

Das könnte Ihnen auch gefallen