Chapter 3 UML
Chapter 3 UML
8/24/2021 3
# The UML Is a Language for Visualizing
-Modeling is often thought to be done mentally, or by just sketching out
a few ideas on a white board.
-However, there are several problems with this.
First, communicating those conceptual models to others is
error-prone unless everyone involved speaks the same language.
Second, there are some things about a software system you
can't understand unless you build models that transcend the textual
programming language.
Third, if the developer who cut the code never wrote down the
models that are in his or her head, that information would be lost
forever or, at best, only partially recreatable from the implementation,
once that developer moved on.
Writing models in the UML addresses these issues.
8/24/2021 4
# The UML Is a Language for Specifying
-Specifying means building models that are precise,
unambiguous, and complete.
-The UML addresses the specification of all the important
analysis, design, and implementation decisions that must
be made in developing and deploying a software-intensive
system.
# The UML Is a Language for Constructing
-The UML is not a visual programming language, but its
models can be directly connected to a variety of
programming languages.
-It is possible to map from a model in the UML to a
programming language such as Java, C++, or Visual Basic,
or even to tables in a relational database or the persistent
store of an object-oriented database.
8/24/2021 5
# The UML Is a Language for Documenting
A healthy software organization produces all sorts of artifacts in
addition to raw executable code. These artifacts include (but are not
limited to)
• Requirements
• Architecture
• Design
• Source code
• Project plans
• Tests
• Prototypes
• Releases
The UML addresses the documentation of a system's architecture and
all of its details. It also provides a language for expressing
requirements and for tests. Finally, the UML provides a language for
modeling the activities of project planning and release management.
8/24/2021 6
Modeling Concepts
- To understand the UML, we need to form a conceptual model of the
language, and this requires learning three major elements: the UML's
basic building blocks, the rules that dictate how those building blocks
may be put together, and some common mechanisms that apply
throughout the UML.
Building Blocks of the UML
The vocabulary of the UML encompasses three kinds of building blocks:
1. Things
2. Relationships
3. Diagrams
(Note: Please refer to the hand written notes shared in the class)
8/24/2021 7
Building Blocks of the UML
UML Category UML Elements UML Elements
Things Structural Things Classes
Interfaces
Collaborations
Use Cases
Active Classes
Components
Nodes
6-9 9
Dependency: A Uses Relationship
# Dependencies
-occurs when one object depends on another
- if you change one object's interface, you need to
change the dependent object
- arrows point from dependent to needed objects
CardReader
Jukebox
CDCollection
SongSelector
6-10 10
Association: Structural Relationship
# Association
- a relationship between classes indicates some
meaningful or interesting connection
-Associations can be labeled getAccountWithID for example
- BTW: The box with association is an official UML comment, must have that fold ☺
associatio
n
getAccountWithI
Jukebo D JukeboxAccountCollectio
1 1
x n
6-11 11
Associations
# Associations imply
-our knowledge that a relationship must be
preserved for some time (0.01 ms to forever)
♦ Between what objects do we need to remember a
relationship?
• Does a Transaction need to remember Account?
• Would AccountCollection need to remember
Accounts?
Store
AccountCollection Accoun
1 s 0..* t
6-12 12
Notation and Multiplicity Adornments
♦ UML Association:
− a line between two concepts and a name
− they are bi-directional * T
zero or more;
"many"
− can have a multiplicity
− exist in class diagrams 1. *
.
T one or
more
1..5
2 T one to fifty
two
5
Multiplicity T exactly
five
adornments
6-13 13
Association
Names • Read these Type-VerbPhrase-Type
• POST is a Point of Sale Terminal)
• Not shown here: Attributes and Methods
• This just shows associations between objects
6-14 14
Aggregation: A Special Association
*
Student
6-16 16
Types of UML Diagrams
8/24/2021 17
Class Diagram shows a set of classes, interfaces, and
collaborations and their relationships. These diagrams are
the most common diagram found in modeling object-
oriented systems.
Class diagrams address the static design view of a system.
Object Diagrams shows a set of objects and their
relationships.
These diagrams represent static snapshots of instances of
the things found in class diagrams.
Use case Diagram shows a set of use cases and actors (a
special kind of class) and their relationships. Use case
diagrams address the static use case view of a system.
These diagrams are especially important in organizing and
modeling the behaviors of a system.
8/24/2021 18
Interaction diagrams
Both sequence diagrams and collaboration diagrams are
kinds of interaction diagrams.
An interaction diagram shows an interaction, consisting
of a set of objects and their relationships, including the
messages that may be dispatched among them.
Interaction diagrams address the dynamic view of a system.
A sequence diagram is an interaction diagram that
emphasizes the time-ordering of messages
Collaboration diagram is an interaction diagram that
emphasizes the structural organization of the objects that
send and receive messages.
** Sequence diagrams and collaboration diagrams are
isomorphic, meaning that you can take one and transform it
into the other.
8/24/2021 19
State chart diagram shows a state machine, consisting of
states, transitions, events, and activities.
-State chart diagrams address the dynamic view of a system.
They are especially important in modeling the behavior of
an interface, class, or collaboration and emphasize the
event-ordered behavior of an object, which is especially
useful in modeling reactive systems.
An Activity diagram is a special kind of a statechart
diagram that shows the flow from activity to activity within
a system.
-Activity diagrams address the dynamic view of a system.
They are especially important in modeling the function of a
system and emphasize the flow of control among objects.
8/24/2021 20
Component diagram shows the organizations and
dependencies among a set of components.
Component diagrams address the static implementation
view of a system. They are related to class diagrams in that
a component typically maps to one or more classes,
interfaces, or collaborations.
Deployment diagram shows the configuration of run-time
processing nodes and the components that live on them.
Deployment diagrams address the static deployment view
of an architecture. They are related to component diagrams
in that a node typically encloses one or more components.
8/24/2021 21
Types of UML Diagrams with Examples
A diagram is the graphical presentation of a set of elements,
most often rendered as a connected graph of vertices (things) and
arcs (relationships)
The UML includes nine such diagrams:
1. Class diagram
2. Object diagram
3. Use case diagram
4. Sequence diagram
5. Collaboration diagram
6. State chart diagram
7. Activity diagram
8. Component diagram
9. Deployment diagram
8/24/2021 22
Class Diagram
• A class diagram shows a set of classes, interfaces, and
collaborations and their relationships.
• Class diagrams are used to model the static design view of a
system.
• For the most part, this involves modeling the vocabulary of the
system, modeling collaborations, or modeling schemas.
• Class diagrams are also the foundation for a couple of related
diagrams: Component diagrams and Deployment diagrams.
# Contents of Class Diagrams
Class diagrams commonly contain the following things:
— Classes
— Interfaces
— Collaborations
— Dependency, generalization, and association relationships
Class Diagrams are generally used to
• To model the vocabulary of a system
• To model simple collaborations
• To model a logical database schema
Class Diagram
Modeling a Schema
Use Case Diagram
A use case diagram is a diagram that shows a set of use cases
and actors and their relationships.
Use case diagrams are one of the five diagrams in the UML for
modeling the dynamic aspects of systems (activity diagrams,
statechart diagrams, sequence diagrams, and collaboration
diagrams are four other kinds of diagrams in the UML for
modeling the dynamic aspects of systems).
Use case diagrams are central to modeling the behavior of a
system, a subsystem, or a class. Each one shows a set of use
cases and actors and their relationships.
# Contents of Use case Diagrams
Use case diagrams commonly contain
— Use cases
— Actors
— Dependency, generalization, and association relationships
Use case Diagrams are generally used to
-To model the context of a system
- To model the requirements of a system
Use Case Diagram
Modeling Context of a System
Figure shows the context of a credit card validation system, with
an emphasis on the actors that surround the system.
Customers here are of two kinds (Individual customer and
Corporate customer).
These actors are the roles that humans play when interacting
with the system.
In this context, there are also actors that represent other
institutions, such as
- Retail institution (with which a Customer performs a card
transaction to buy an item or a service) and
- Sponsoring financial institution (which serves as the
clearinghouse for the credit card account). In the real world,
these latter two actors are likely software-intensive systems
themselves.
Modeling the Requirements of a System
Object Diagram
Object diagrams model the instances of things contained in
class diagrams.
An object diagram shows a set of objects and their
relationships at a point in time.
Object diagrams are used to model the static design view or
static process view of a system. This involves modeling a
snapshot of the system at a moment in time and rendering a set
of objects, their state, and their relationships.
# Contents of Object Diagrams
Object diagrams commonly contain
— Objects
— Links
#Object Diagrams are generally used to
— To model object structures
Object Diagram
Interaction Diagram
Sequence diagram & Collaboration diagram
Sequence diagrams and collaboration diagrams together are called
interaction diagrams
They are used for modeling the dynamic aspects of systems.
An interaction diagram shows an interaction, consisting of a set of
objects and their relationships, including the messages that may be
dispatched among them.
Interaction diagrams commonly contain
• Objects
• Links
• Messages
A sequence diagram is an interaction diagram that emphasizes the
time ordering of messages
A collaboration diagram is an interaction diagram that emphasizes the
structural organization of the objects that send and receive messages.
Sequence Diagram
Sequence diagrams have two features that distinguish them from
collaboration diagrams.
First, there is the object lifeline. An object lifeline is the vertical
dashed line that represents the existence of an object over a
period of time. Most objects that appear in an interaction
diagram will be in existence for the duration of the interaction,
so these objects are all aligned at the top of the diagram, with
their lifelines drawn from the top of the diagram to the bottom.
Second, there is the focus of control. The focus of control is a
tall, thin rectangle that shows the period of time during which an
object is performing an action, either directly or through a
subordinate procedure. The top of the rectangle is aligned with
the start of the action; the bottom is aligned with its completion
(and can be marked by a return message).
Collaboration Diagram
Collaboration diagrams have two features that
distinguish them from sequence diagrams.
First, there is the path, to indicate how one object
is linked to another
Second, there is the sequence number, to indicate
the time order of a message.
The message is prefixed with a number (starting with
the message numbered 1), increasing monotonically for
each new message in the flow of control (2, 3, and so
on).
Sequence diagrams and collaboration diagrams are
semantically equivalent.
Statechart Diagram
Statechart diagram shows flow of control from state to state.
Statechart diagrams are one of the five diagrams in the UML for
modeling the dynamic aspects of systems.
A statechart diagram shows a state machine.
Statechart diagrams are not only important for modeling the
dynamic aspects of a system, but also for constructing executable
systems through forward and reverse engineering.
Statechart Diagram
# Contents of Statechart Diagram
Statechart diagrams commonly contain
• Simple states and composite states
• Transitions, including events and actions
# Statechart diagrams are generally used
To model a reactive object,
Activity Diagram
-Activity diagrams are used to model the dynamic aspects of a system.
Graphically, an activity diagram is a collection of vertices and arcs.
- An activity diagram shows the flow from activity to activity. An is an
ongoing nonatomic execution within a state machine.
- Activities ultimately result in some action, which is made up of
executable atomic computations that result in a change in state of the
system or the return of a value.
- Actions encompass calling another operation, sending a signal,
creating or destroying an object, or some pure computation, such as
evaluating an expression.
- Activity diagrams may stand alone to visualize, specify, construct,
and document the dynamics of a society of objects, or they may be
used to model the flow of control of an operation.
Activity Diagram
# Contents of Activity Diagram
Activity diagrams commonly contain
• Activity states and action states
• Transitions
• Objects
# Action States and Activity States
Executable, atomic computations are called Action States
because they are states of the
system, each representing the
execution of an action
The above slides have clearly explained all UML diagrams with
suitable examples.
User Centred Design
8/24/2021 58
The importance of focusing on users
8/24/2021 59
Characteristics of Users
8/24/2021 60
Basics of User Interface Design
8/24/2021 61
Usability vs. Utility
Does the system allow the user to learn and to use the
raw capabilities easily?
• This is usability.
8/24/2021 62
Aspects of usability
8/24/2021 63
Some basic terminology of user interface
design
• Dialog: A specific window with which a user can interact, but
which is not the main UI window.
• Control or Widget: Specific components of a user interface.
• Affordance: The set of operations that the user can do at any given
point in time.
• State: At any stage in the dialog, the system is displaying certain
information in certain widgets, and has a certain affordance.
• Mode: A situation in which the UI restricts what the user can do.
• Modal dialog: A dialog in which the system is in a very restrictive
mode.
• Feedback: The response from the system whenever the user does
something, is called feedback.
• Encoding techniques. Ways of encoding information so as to
communicate it to the user.
8/24/2021 64
Usability Principles
1. Do not rely only on usability guidelines – always test
with users.
• Usability guidelines have exceptions; you can only be
confident that a UI is good if you test it successfully
with users.
2: Base UI designs on users’ tasks.
• Perform use case analysis to structure the UI.
3: Ensure that the sequences of actions to achieve a task
are as simple as possible.
• Reduce the amount of reading and manipulation the user
has to do.
• Ensure the user does not have to navigate anywhere to
do subsequent steps of a task.
8/24/2021 65
Usability Principles
8/24/2021 66
Usability Principles
8/24/2021 67
Usability Principles
8/24/2021 68
Usability Principles
8/24/2021 69
Usability Principles
12. Be consistent.
• Use similar layouts and graphic designs throughout your
application.
• Follow look-and-feel standards.
• Consider mimicking other applications.
8/24/2021 70
Some encoding techniques
8/24/2021 71
Example
(bad UI)
8/24/2021 72
Example
(better UI)
8/24/2021 73
Difficulties and Risks in UI Design
8/24/2021 74
Difficulties and Risks in UI Design
8/24/2021 75