Object Technology & UML
Object Technology & UML
Object Technology & UML
Introduction to UML
of UML
m unified refers to the fact that the Object
ent Group (OMG), an industry-recognized
dization organization and Rational software
tion created the UML to bring together the information
tion systems and technology industry’s best
ring practices. Booch by Grady Booch, OMT by Jim
Rumbaugh and OOSE by Ivar Jacobson
baugh, Ivar Jacobson and Grady Booch decided at
at the end of 1994 to unify their work within a single
method – “The unified method”.
Definition of UML:
A visual language for modeling and communicating
about systems through the use of diagrams and
supporting text this is known as Unified Modeling
Language.
Chennai
(City)
Arpita
(Employee)
(Association)
• Associations are descriptions of links or a set of links
with a common implementation.
• Associations –
• Are classes that relate other classes.
• Are to links as classes are to objects.
• Define an implementation for their links.
• Association can have the following –
• Name: Identifies the association type.
• Multiplicity: Indicates that how many objects can
participate in the association.
• Role: Meaning of the classes involved.
• Associations have a multiplicity attribute. The
multiplicity denotes the cardinality of the
association. The multiplicity of an association
end is the number of possible instances of the
class associated with a single instance of the
other end. Multiplicities are single numbers or
ranges of numbers.
Employee
0..n manager of
works-for
• Ternary Association: The association which contain
the degree of three classes is called binary
association
0..* 0…*
Meta model:
A model that describes model elements and meta
modeling is the recursive modeling of model elements
from themselves.
OBJECT CONSTRAINT LANGUAGE (OCL)
Male Female
Specialization Generalization
When we create a superclass ‘Human’ using two
subclasses ‘Male’ and ‘Female’ this process is called
Generalization whereas When we create two
subclasses ‘Male’ and ‘Female’ using a single
superclass ‘Human’ this is called specialization.
Aggregation vs. Generalization
Aggregation and Generalization both are different
concepts. Aggregation provides the relationship
between objects and classes, while Generalization is a
process to combine the common behaviour and
attributes in a single class or more classes.
Generalization Aggregation
When we create a super-class ‘Human’ using two
subclasses ‘Male’ and ‘Female’ this process is called
Generalization whereas Legs, Hands, Head and Body
are parts of Human class that show example of
aggregation
Generalization vs. Inheritance
Generalization is the relationship between a class and
one or more refined versions of it. The class being
refined is called the superclass and each refined
version is called subclasses. Attributes and operations
common to a group of subclasses are attached to the
superclass and changed by each subclass. Each
subclass is said to inherit the features of its
superclass.
Generalization and inheritance are transitive across an
arbitrary number of levels.
Actually we use Generalization to refer to the
relationship among classes, while inheritance refers to
the mechanism of sharing attributes and operations
using the Generalization relationship.
ARCHITECTURAL VIEWS AND MODEL VIEWS
Architectural views:
Architectural views are abstractions of models.
Knowledge
Model
(Architectu
re)
Architectura Diagrams
l views (Views)
Model
Elements
Model views:
Use-case
• Visibility
Use visibility markers to signify who can access the
information contained within a class. Private visibility
hides information from anything outside the class
partition. Public visibility allows all other classes to
view the marked information. Protected visibility allows
child classes to access information they inherited from
a parent class.
• Associations
Associations represent static relationships between
classes. Place association names above, on, or below
the association line. Use a filled arrow to indicate the
direction of the relationship. Place roles near the end
of an association. Roles represent the way the two
classes see each other.
Note: It's uncommon to name both the association
and the class roles.
• Multiplicity (or Cardinality)
Place multiplicity notations near the ends of an
association. These symbols indicate the number of
instances of one class linked to one instance of the
other class. For example, one company will have one
or more employees, but each employee works for one
company only.
• Constraint
Place constraints inside curly braces {}.
Composition and Aggregation
• Composition is a special type of aggregation that denotes
a strong ownership between Class A, the whole, and
Class B, its part. Illustrate composition with a filled
diamond. Use a hollow diamond to represent a simple
aggregation relationship, in which the "whole" class plays
a more important role than the "part" class, but the two
classes are not dependent on each other. The diamond
end in both a composition and aggregation relationship
points toward the "whole" class or the aggregate.
Generalization
Generalization is another name for inheritance or an "is a"
relationship. It refers to a relationship between two classes
where one class is a specialized version of another. For
example, Honda is a type of car. So the class Honda
would have a generalization relationship with the class car.
In real life coding examples, the difference between
inheritance and aggregation can be confusing. If you have
an aggregation relationship, the aggregate (the whole) can
access only the PUBLIC functions of the part class. On the
other hand, inheritance allows the inheriting class to
access both the PUBLIC and PROTECTED functions of
the super class.
OBJECT DIAGRAM:
• WHAT IS A UML OBJECT DIAGRAM?
Object diagrams are also closely linked to class
diagrams. Just as an object is an instance of a class,
an object diagram could be viewed as an instance of a
class diagram. Object diagrams describe the static
structure of a system at a particular time and they are
used to test the accuracy of class diagrams.
Basic Object Diagram Symbols And Notations
Object names:
• Each object is represented as a rectangle, which
contains the name of the object and its class
underlined and separated by a colon. Both names are
optional and the colon is only present if the class is
specified.
• Object attributes
As with classes, you can list object attributes in a
separate compartment. However, unlike classes,
object attributes must have values assigned to them.
• Active object
Objects that control action flow are called active
objects. Illustrate these objects with a thicker border.
• Multiplicity
You can illustrate multiple objects as one symbol if the
attributes of the individual objects are not important.
• Links
Links are instances of associations. You can draw a
link using the lines used in class diagrams.Learn how
to connect objects.
• Self-linked
Objects that fulfill more than one role can be self-
linked. For example, if Mark, an administrative
assistant, also fulfilled the role of a marketing
assistant, and the two positions are linked, Mark's
instance of the two classes will be self-linked.
Assignment:
Draw object diagram for the following object classes,
with association names attributes and additional
object classes if required.
Object classes: college, playground, principal, classroom,
board, book, student, faculty, cafeteria, ruler, door, swing.
USE-CASE DIAGRAMS:
• Use case is a specification technique for functional
needs as perceived by a category of users.
• Use cases can be represented graphically in a use
case diagram, each use case being described in the
data dictionary.
• Use cases may be modeled at varying degrees of
abstraction, essential use cases, the most abstract,
are technologically and implementation independent
whereas real use cases describe how the use case
actually operates in a particular environment.
• So, a use case diagram shows actors and use cases,
together with various relations between them.
• A use case denotes a typical type of task that a user
can perform with a system. An actor represents a role
that a user can play when interacting with a system.
Actors are association can be related by
generalization, to make explicit their shared
capabilities.
• Use case diagrams model the functionality of system
using actors and use cases.
• A use case is a set of scenarios that describing an
interaction between a user and a system. A use case
diagram displays the relationship among actors and
use cases. The two main components of a use case
diagram are use cases and actors.
• Use Case
Draw use cases using ovals. Label with ovals with
verbs that represent the system's functions.
• Actors
Actors are the users of a system. When one system is the
actor of another system, label the actor system with the
actor stereotype.
• Relationships
Illustrate relationships between an actor and a use case
with a simple line. For relationships among use cases, use
arrows labeled either "uses" or "extends." A "uses"
relationship indicates that one use case is needed by
another in order to perform a task. An "extends"
relationship indicates alternative options under a certain
use case.
Assignment:
A State Bank of India (SBI) has installed ATM to offer
basic service round the clock and the functional
requirement of the system are :
• The SBI client must be able to deposit or withdraw an
amount to/from his account using the ATM counter. Each
transaction has to be recorded and the client must be
able to review all transaction performed in his account.
• Access to the SBI account is provided by a PIN code.
• The system should be designed such that it automatically
checks the client account. If the amount to be withdrawn
exceeds the amount in the account of the client then it
should check whether the client could avail the overdraft
facility as per the SBI rules.
Draw a use-case diagram according to the above
scenario.
SEQUENCE DIAGRAMS:
• A sequence diagram or interaction diagram that shows
an interaction between objects arranged in a time
sequence. Sequence diagrams can be draw at
different levels of detail and also to meet different
purposes at several stages in the development life
cycle.
• Sequence diagrams describe interactions among classes in
terms of an exchange of messages over time. A horizontal axis
shows the elements involved in the interaction and a vertical
axis represents time proceeding down the page.
• Sequence diagrams have the following types of elements:
– Classes and Objects
• Classes are shown much the same way as on class diagrams.
Objects may also be shown much the same way as on object
diagrams.
– A lifeline
• Shown as a vertical dashed line from an element, this
represents the existence of the element over time.
– A communication
• Shown as a horizontal solid arrow from the lifeline of the sender
to the lifeline of the receiver and labeled with the name of the
operation to be invoked, this represents that the sender sends a
message or stimulus to the receiver.
• Sequence diagrams describe interactions among classes in
terms of an exchange of messages over time.
Basic Sequence Diagram Symbols And Notations
• Class roles
Class roles describe the way an object will behave in
context. Use the UML object symbol to illustrate class
roles, but don't list object attributes.
• Activation
Activation boxes represent the time an object needs to
complete a task.
• Messages
Messages are arrows that represent communication
between objects. Use half-arrowed lines to represent
asynchronous messages. Asynchronous messages
are sent from an object that will not wait for a
response from the receiver before continuing its tasks.
• Various message types for Sequence and
Collaboration diagrams
• Lifelines
Lifelines are vertical dashed lines that indicate the
object's presence over time.
• Destroying Objects
Objects can be terminated early using an arrow
labeled "< < destroy > >" that points to an X.
• Loops
A repetition or loop within a sequence diagram is
depicted as a rectangle. Place the condition for exiting
the loop at the bottom left corner in square brackets [
].
Assignment:
Draw a sequence diagram for the cellular
phone connection.
COLLABORATION DIAGRAMS
• A collaboration diagram that shows an interaction
between objects and the context of the interaction in
terms of the links between the objects.
• Collaboration diagrams represent interactions
between objects as a series of sequenced messages.
• Association roles
Association roles describe how an association will
behave given a particular situation. You can draw
association roles using simple lines labeled with
stereotypes.
• Messages
Unlike sequence diagrams, collaboration diagrams do
not have an explicit way to denote time and instead
number messages in order of execution. Sequence
numbering can become nested using the Dewey
decimal system. For example, nested messages
under the first message are labeled 1.1, 1.2, 1.3, and
so on. The a condition for a message is usually placed
in square brackets immediately following the
sequence number. Use a * after the sequence number
to indicate a loop.
• Collaboration diagrams are also relatively easy to draw. They
show the relationship between objects and the order of
messages passed between them. The 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. There
are many acceptable sequence numbering schemes in UML. 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.
• The example below shows a simple collaboration
diagram for the placing an order use case. This time
the names of the objects appear after the colon, such
as :Order Entry Window following the objectName:
className naming convention. This time the class
name is shown to demonstrate that all of objects of
that class will behave the same way.
STATE CHART DIAGRAMS or STATE DIAGRAMS:
• Statecharts can be used to specify the behaviour of
classes that display statedependent behaviour. They
illustrate the sequences of messages that can be sent
to an object and the response that an object might
make to a message at different times. A state
diagrams also known as statechart diagram, depict the
lifecycle of an element. The state of an object is
determined by values of some its attributes and the
presence or absence of certain links with other
objects.
• State chart diagrams describe the dynamic behavior of
a system in response to external stimuli. State chart
diagrams are especially useful in modeling reactive
objects whose states are triggered by specific events.
• 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 track
the different states of its objects through the system.
• A state chart diagram shows the behavior of classes in
response to external stimuli. This diagram models the
dynamic flow of control from state to state within a
system.
Basic State chart Diagram Symbols And Notations
• States
States represent situations during the life of an object.
You can easily illustrate a state in SmartDraw by using
a rectangle with rounded corners.
• Transition
A solid arrow represents the path between different
states of an object. Label the transition with the event
that triggered it and the action that results from it.
Fig. Initial State Fig. Final State Fig.
• Initial State
• A filled circle followed by an arrow represents the object's
initial state.
• Final State
• An arrow pointing to a filled circle nested inside another
circle represents the object's final state.
• Synchronization and Splitting of Control
• A short heavy bar with two transitions entering it
represents a synchronization of control. A short heavy bar
with two transitions leaving it represents a splitting of
control that creates multiple states.
When to Use: State Diagrams
• Use state diagrams to demonstrate the behavior of an
object through many use cases of the system. Only
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. State diagrams are other combined with other
diagrams such as interaction diagrams and activity
diagrams.
How to Draw: State Diagrams
• State diagrams have very few elements. The basic
elements are rounded boxes representing the state of
the object and 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.
• All state diagrams being with 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.
Assignment:
• Draw a state chart diagram, which explains the
various states of making a phone call.
• A passenger calls the lift from its current floor and
after entering the lift the passenger presses the
destination button. The lift on arrival at destination
will wait for next response up to a time limit. If there
is no response within the time, the lift will go back to
its home floor that is ground floor. Represent these
features with the help of state diagrams.
ACTIVITY DIAGRAMS:
• A activity diagram is a variation of a state chart
diagram that focuses on a flow of activity driven by
internal processing within an object rather than by
events that are external to it. In an activity diagram
most states are action, each of which represents the
execution of an operation.
• Activity diagrams illustrate the dynamic nature of a system by
modeling the flow of control from activity to activity. An activity
represents an operation on some class in the system that
results in a change in the state of the system. Typically, activity
diagrams are used to model workflow or business processes
and internal operation.
• Activity diagrams describe the workflow behavior of a
system. Activity diagrams are similar to state diagrams
because activities are the state of doing something. The
diagrams describe the state of activities by showing the
sequence of activities performed. Activity diagrams can show
activities that are conditional or parallel.
• An activity diagram illustrates the dynamic nature of a system
by modeling the flow of control from activity to activity. An
activity represents an operation on some class in the system
that results in a change in the state of the system. Typically,
activity diagrams are used to model workflow or business
processes and internal operation. Because an activity diagram
is a special kind of statechart diagram, it uses some of the
same modeling conventions.
Basic Activity Diagram Symbols And Notations
• Action states
Action states represent the noninterruptible actions of
objects. You can draw an action state in SmartDraw
using a rectangle with rounded corners.
• Action Flow
Action flow arrows illustrate the relationships among
action states.
Fig. Object Flow Fig. Initial State Fig. Final State
• Object Flow
Object flow refers to the creation and modification of objects by
activities. An object flow arrow from an action to an object
means that the action creates or influences the object. An
object flow arrow from an object to an action indicates that the
action state uses the object.
• Initial State
A filled circle followed by an arrow represents the initial action
state.
• Final State
An arrow pointing to a filled circle nested inside another circle
represents the final action state.
Fig. Branching Fig. Synchronization
• Branching
A diamond represents a decision with alternate paths.
The outgoing alternates should be labeled with a
condition or guard expression. You can also label one
of the paths "else.“
• Synchronization
A synchronization bar helps illustrate parallel
transitions. Synchronization is also called forking and
joining.
• Swimlanes
Swimlanes group related activities into one column. Read this this flowchart
tutorial to learn how to create swimlanes in SmartDraw.
• Component
A component is a physical building block of the system. It is
represented as a rectangle with tabs.
• Interface
An interface describes a group of operations used or created by
components.
• Dependencies
Draw dependencies among components using dashed arrows.
DEPLOYMENT DIAGRAMS:
• A deployment diagram that shows the run-time configuration of
processing nodes and the components, processes and objects
that are located on them.
• Deployment diagrams depict the physical resources in a
system, including nodes, components, and connections.
Basic Deployment Diagram Symbols And Notations
Deployment diagrams have the following types of elements:
Node
A node is a physical resource that executes code components.
Shown as 3D rectangle, this represents a resource that is
available during execution time.
Association
Shown as a solid line path between nodes. Association refers
to a physical connection between nodes, such as Ethernet.
Components and Nodes
Place components inside the node that deploys them.
CASE STUDIES:
1. Draw a state chart diagram, which explains the
various states of making a phone call.