UML - EL626

advertisement
An Introduction to the Unified
Modeling Language
A picture is worth a thousand words
Introduction
 Most people refer to the Unified Modeling
Language as UML.
 An international industry standard graphical
notation for describing software analysis and
designs.
 a standardized notation is used, in order to
minimize the room for misinterpretation.
 Therefore the error rate will be less.
Continued on next slide
Introduction
 The U in UML stands for unified because the
UML is a unification and standardization of
earlier modeling notations of Booch,
Rumbaugh, Jacobson, Mellor and Shlaer.
 The UML has been accepted as a standard by
the Object Management Group1 (OMG).
 OMG is a non-profit organization with about
700 members that sets standards for
distributed object oriented computing.
Use Case Diagrams
 Use case- a concept invented by Ivar Jocbson.
 Use case typically represents a major piece of
functionality that is complete from beginning to
end.
 Use case diagrams are used during requirements
collection and analysis as a graphical means of
representing the functional requirements of the
system.
 In UML, a use case is represented as an ellipse
Who is an actor?
 An actor represents whoever or whatever
interacts with the system.
 The actor is not part of the system itself and
represents anyone or anything that must interact
with the system to:
• Input information to the system;
• Receive information from the system;
• Both input information to and receive
information from the system.
UML SYMBOL FOR AN ACTOR
• Arrows and lines are draw between actors
and use cases and between use cases to show
their relationships
There are two kinds of relationships between
use cases. They are:
 «include»
 «extend»
 The «include» relationship when a chunk of
behavior is similar across more than one use-case,
and you don’t want to keep copying the description
of that behavior
 The «extend» relationship allows us to modify the
behaviour of the base Use Case.
But extend relationship makes the use cases difficult to
understand. So the developers very rarely use this
relationship.
Representation of include and extend
relationship
Class Diagrams
 A class diagram in the Unified Modeling
Language is a type of static structure diagram
that describes the structure of a system by
showing the system's classes, their attributes,
operations, and the relationships among
objects.
 Class diagrams are used in both the analysis
and the design phases.
 In UML, a class is represented by a rectangle
with one or more horizontal compartments.
 The upper compartment holds the name of the
class. The name of the class is the only required
field in a class diagram.
 The center compartment of the class rectangle
holds the list of the class attributes/data
members.
 The lower compartment holds the list of
operations/methods.
• The complete UML notation for a class is
Static Relationships
 There are two principle types of static
relationships between classes: inheritance and
association.
 The relationships between classes are drawn
on class diagram by various lines and arrows.
Inheritance
 Inheritance is represented with an empty
arrow, pointing from the subclass to the super
class.
Association
 An association represents a relationship
between two instances of classes.
 An association between two classes is shown
by a line joining the two classes.
 Association indicates that one class utilizes an
attribute or methods of another class.
 There are two different specialized types of
association relationships: aggregation, and
composition.
Aggregation
• If the association conveys the information that
one object is part of another object, but their
lifetimes are independent (they could exist
independently), this relationship is called
aggregation.
Composition
 Composition is, when an object is contained
in another object, and it can exist only as long
as the container exists and it only exists for
the benefit of the container.
Attributes
 Attributes or data members are shown in the
middle box of the class diagram. It is optional
to show the attributes.
 Public attributes are denoted with a + sign,
protected with a # sign, and private with a –
sign.
Notation for Attributes
Operations
• The operations are the services that a class is
responsible for carrying out. They may be
specified giving their signature (the names
and types of their arguments/parameters), the
return type, and their visibility (private,
protected, public).
Notation for Operations
More Advanced Class Diagram
Concepts
 Abstract Classes
– If there is an abstract class or method, the UML
convention is to italicize the name of the abstract
item.
 Packages
– If a system is big, it should be partitioned in
smaller sub-systems, each with its own class
diagram. In UML notation, the partitions/subsystems are called packages.
 Stereotypes
– Stereotypes are a high-level classification of an
object that gives you some indication of the kind
of object it is.
 Notes
– Notes are used to “attach” comments and
constraints to the model elements.
Object Diagrams
 An UML object diagram, on the other hand,
shows a snapshot of the detailed state of a
system at a point in time.
 An UML object diagram shows some specific
instance of the classes of the system. While there
is only class diagram of the system, there may be
hundreds of different object diagrams.
 In an object diagram, many different instances of
the same class, and no instance of other classes,
may be shown.
Notation for an object
Sequence Diagrams
 Sequence diagrams are used in the analysis
and design phases.
 By creating a sequence diagram, the objects
that participate in the use case are identified.
 Sequence diagrams highlight the sequence of
messages through time.
 But they do not show how objects are linked
and may send messages to each other.
A sequence diagram representing a
player taking a turn
State Diagrams
 State diagrams are created during the
analysis and design phase to describe the
behavior of nontrivial objects.
 State diagrams are good for describing the
behavior of one object across several use
cases.
It is used to identify object attributes and to
refine the behavior description of an object.
 A state diagram consists of:
• A state is represented by a rounded rectangle.
• A start state is represented by a solid circle.
• A final state is represented by a solid circle with
another open circle around it.
• A transition is a change of an object from one
state (the source state) to another (the target
state) triggered by events, conditions, or time.
UML State Diagram for a Turn in
Monopoly
Activity Diagrams
 Activity diagrams are used during the design
phase of complex methods.
 The activity diagram can also be used during
analysis to break down the complex flow of a
use case.
 UML activity diagrams are an updated and
enhanced form of flowcharts.
An activity diagram explaining how to
prepare corn on the cob
Conclusion
• Powerful modelling language.
• UML can be used for modelling the whole
system independent of platform language.
• Provide users with a ready-to-use, expressive
modelling examples
Reference
An Introduction to the Unified Modeling
Language : Laurie Williams 2004
Download