Unit 3(Fund. of Se)-Part III
Unit 3(Fund. of Se)-Part III
Structural Model
1
Class Diagram
Modelling a system involves identifying the things that are important to your
particular view.
These things form the vocabulary of the system you are modelling.
This part explores how we do basic modelling of things and concepts from the real-
world
Using Class Diagrams
A class is a definition of objects that share the same properties, relationships and
behavior.
An object is an instance of a class(or structure).
The properties of a class are called attributes and the behavior is expressed in
2
operations.
Class Diagram------
Class Diagrams are widely used to describe the types of objects in a system and their relationships.
The class model also describes the attributes and operations of the class along with the visibility of each.
Class Diagrams model class structure and contents using design elements such as classes, packages and
objects.
Class diagrams are used in nearly all object oriented software designs.
They are used to describe the classes of the system and their relationships to each other.
Class diagrams are used to model the static design view of a system
1. Forward Engineering:
It is the process of transforming a model into code through a mapping to an
implementation language
5
Forward & Reverse Engineering------
2. Reverse Engineering:
It is the process of transforming code into model through a mapping from
Especially true for class diagrams, whose contents have a clear mapping
6
Class Representation
Classes are the most important building block of any object-oriented system
Classes are used : -
To capture the vocabulary of the system you are developing
To represent software things, hardware things, and even things that are purely
conceptual
Well-structured classes have crisp boundaries and form a part of a balanced
distribution of responsibilities across the system
Class Name
attributes
operations
9
Name
can be a path name-the class name prefixed by the name of the package in which that class lives,
Attribute
An attribute is a named property of a class that describes a range of values that instances of the
At any given moment, an object of a class will have specific values for every one of it’s class
Customer Wall
name height : Float
address width : Float
phone thickness : Float
birthdate isLoadBearing : Boolean
= false
(a)
(b)
11
Attributes-----
12
Operation
An operation is the implementation of a service that can be requested from any
object of the class to affect behaviour
Often, invoking an operation on an object changes the object’s data or state
A class may have a number of operations or no operations at all.
Operations may be drawn showing only their names (a)
We can further specify an operation stating its signature (b)
including the name, type and default value of all parameters and (in case of
functions) a return type
13
Customer TemperatureSen
sor
add()
remove() reset()
(a) edit() (b) setAlarm(t :
Temperature)
value() :
Operations define the behavior of the objects Temperature
Action performed on or by an object
Available for all instances of the class
Methods/operations has visibility (private, protected, public)
Need not be unique among classes
14
Relationships
A relationship is, the logical or physical connections found on class diagrams.
A Link is the basic relationship among objects-represented as a line connecting two
or more object boxes.
A link is an instance of an association. In other words, it creates a relationship
between two classes.
When we build abstractions, we will discover that very few classes stand alone
Therefore, when we model a system, we must
Identify the things that form the vocabulary of our system (classes)
15
Relationships------
Model how these things stand in relation to one another
In UML, the ways that things can connect to one another, either logically or
physically, are modelled as relationships
In object-oriented modelling, there are three kinds of relationships that are most
important
1. Dependencies- represents ‘using’ relationship among classes
2. Generalizations
Connects generalized classes to more specialized ones in what is known as
subclass/super-class or child/parent relationship (inheritance)
16
Relationships------
3. Associations
It represents structural relationships among instances/objects
Each of these relationships provides a different way of combining our abstractions
(classes).
The UML provides a graphical representation for each of these kinds of
relationships
allows us to visualize relationships
emphasize the most important parts of a relationship: its name, the things it
connects, and its properties
17
A. Dependency
A dependency is a using relationship that states that a change in specification of one thing
(independent thing) may affect another thing that uses it (dependent thing), but not
necessarily the reverse
It is rendered as a dashed directed line
dependent independent
Dependencies are used in the context of classes to show that one class uses another class as
an argument in the signature of an operation.
If the used class changes, the operation of the other class may be affected
The most common kind of dependency relationship is the connection between a class that
only uses another class as a parameter to an operation.
18
A. Dependency------
20
B. Generalization-----
Graphically, a generalization is rendered as a solid directed line
with a large open arrowhead, pointing to the parent
21
B. Generalization--------
A class may have zero, one or more parent
A class that has no parent and one or more children is called a root or base class
A class that has no children is called a leaf class
A class that has exactly one parent is said to use single inheritance
A class that has more than one parent is said to use multiple inheritance
A given class cannot be its own parent
We will often use generalizations among classes and interfaces to show inheritance
relationships.
It can also create generalizations with packages
22
B. Generalization--------
To model inheritance relationship
Given a set of classes, look for responsibilities, attributes and operations that are
common to two or more classes
Elevate those common responsibilities, attributes and operations to a more general
class.
If necessary, create a new class to which you can assign these elements
Specify that the more-specific classes inherit from the more-general class by placing a
generalization relationship that is drawn from each specialized class to its more-
general parent
23
B. Generalization--------
Example: - The Rectangle, Circle and Polygon classes inherits
from the attributes and operations of the Shape class
24
C. Association
An association is a structural relationship that specifies that objects of one thing are
versa
Types of association: -
1. Unary Association- is where both ends of an association circle back to the same
class
26
C. Association------
2. Role
When a class participates in an association, it has a specific role that it plays in the
relationship
A role is just the face that the class at the near end of the association presents to the class at
the other end of the association
An explicit name can be given to the role a class plays in an association
27
C. Association------
3. Multiplicity
It is important to state how many objects may be connected across an instance of an association
This “how many” is called multiplicity of an association’s role
It is written as an expression that evaluates to a range of values or an explicit value/ Multiplicity
can be written as multiplicity of:
Exactly one (1)
Zero or one (0..1)
Many (*)
28
D. Aggregation
It is a “whole-part” relationship within which one or more smaller class are
“part” of a larger “whole”
It represents a “has-a” relationship, whereby an object of the whole class has
objects of the part
29
Modelling Relationships
30
Simple Example: To Model a Class Diagram
31
Simple Example: To Model a Class Diagram------
Each PASSWORD entered must be more than 8 characters and consists of a combination of text
and numbers
Each registered CUSTOMER, upon ACCOUNT verification, can REVIEW one or more BOOKs
based on its title
A REVIEW can either be a customer’s review and editor’s review
1. Identify the things found in the problem
Account
Password
Customer
Book
Review
32
Simple Example: To Model a Class Diagram------
Book
Used to keep the relevant information on the book that is crucial to customer’s review, i.e. book
title, author, rating
Review
Divided into sub-classes: CustomerReview and EditorialReview
CustomerReview
Used to assign ratings to book reviewed (with 1 being the lowest and 5 the highest) by customer
Used to compute the average rating for each book that has been reviewed by customer
EditorialReview
Used to store editor’s review
34
Simple Example: To Model a Class Diagram------
3. Translate the responsibilities for each class into attributes and operations needed to
perform those responsibilities.
Account
Attributes: emailAddress(string), ID(string), passwd(Password)
Operations: verifyPassword(p: Password)
Password
Attributes: passwd(string)
Operations: checkPassword()
Customer
Attributes: CustName, CustAddress, CustID etc
Operations: NONE
35
Simple Example: To Model a Class Diagram------
Can choose not to show the attributes when modeling the class as they are not relevant to the
given problem (put NONE for both)
Book
Attributes: title, author, rating
Operations : NONE
Review
Attributes: NONE
Operations: NONE
CustomerReview
Attributes: NONE
Operations: assignRatings(rating : Int), computeAvgRating() : double
36
Simple Example: To Model a Class Diagram------
EditorialReview
Attributes: NONE
Operations: NONE
4. Determine the relationship between classes: -
Dependency
The operation verifyPassword in Account class has as parameter a Password class
Therefore, Account depends on Password
Generalization
Review can be divided into customer’s review and editor’s review
37
Simple Example: To Model a Class Diagram------
38
5. Modelling the classes Diagram EditorialReview
Book
title : has
String Review
1 *
40
Object Diagrams
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
You use object diagrams to model the static design view or static
process view of a system.
involves modelling a snapshot of the system at a moment in time
and rendering a set of objects, their state, and their relationships
41
The UML notation for an object takes the same form as that for a class, except for
3 differences:
Within the top compartment of the class box, the name of the class to which the
object belongs to appears after a colon :
The object may have a name that appears before the colon, or it may be
anonymous (no name before the colon)
The contents of the top compartment are underlined for an object.
Each attribute defined for the given class has a specific value for each object
that belong to that class.
43
Example: From the class diagram given below, you can
get several instances of it.
Author Book
name : String wrote title : String
rating: Double
published by
Publisher
name : String
44
: Author : Book
name : “Margeret Mitchell” wrote title : “Gone With the Wind”
rating: 4.5
published by
AW: Publisher
name : “Hawthorne”
Object diagram
45
: Author : Book
name : “Tim Burton” wrote title : “Burton on Burton”
rating: 4
published by
AW: Publisher
name : “Barnes”
Object diagram
46
3. Sequences Diagram
Interaction Diagram:
Expressing How Things Work Together
47
Modelling an Interaction
When modelling an interaction, we need to include
both objects and messages
1. Each object plays a specific role
2. Each message represents the communication between objects,
with some resulting action
These dynamic aspect may involve : -
The interaction of any kind of instance in any view of
a system’s architecture, including instances of a class, interface,
components and nodes.
A system as a whole, a subsystem, an operation or a class.
48
Modelling an Interaction---------
49
3. Sequences Diagram
50
3. Sequences Diagram----------
Each use cases in a use-case diagram has its corresponding sequence or collaboration
diagram
A sequence diagram has four key elements: -
1. Objects appear along the top margin
2. Lifeline, which is a dashed line that represent the life and perhaps death of the object
3. A focus of control, which is a tall thin rectangle that sits on top of an object’s lifeline
It shows the period of time during which an object is performing an action, either directly
or through subordinate procedure
The bottom part of a focus of control can be marked by a return message
4. Messages show the actions that objects perform on each other and on themselves.
You model the diagrams
51 from the main flow of events, or the alternate flow of events, or
3. Sequences Diagram======
Every object that you have identified in the sequence or collaboration diagram,
MUST have its corresponding class in the class diagram
To Model a Sequence Diagram: -
Set the context for the interaction
Whether it is a system, subsystem, operation, class or a scenario of a use case or
collaboration
Identify which objects play a role in the interaction
Place them from left-to-right, at the top of the diagram
Set the lifeline for each object
52
Messages & Actions
A message is a communication between two objects, or within an object, that is
designed to result in some activity.
This activity involves one or more actions, which are executable statements that
result in
Changes in the values of one or more attributes of an object, or
The return of some value(s) to the object that sent the message, or both.
There are 5 kinds of actions that the UML explicitly supports:
Call and Return
Create and Destroy
Send
53
A. Call Action: A call action invokes an operation on an object
It is synchronous, meaning that the sender assumes that the receiver is ready to accept the
message,
And the sender waits for a response from the receiver before proceeding
The UML represents a call action as an arrow from the calling object to the receiving
object
action name
A call action from an
54 object to itself
B. Return Action
A return action is the return of a value to the caller, in response to a call action
The UML represents a return action as a dashed arrow from the object returning the
value to the object receiving the value
return value
55
Example :- Call and Return action
: Customer : CustomerReview
assignRating()
computeAvgRating()
average rating
56
C. Create Action
A create action creates an object
It tells a class to create an instance of itself
In the UML, create action is represented as an arrow with the stereotype <<create>> from the
object that invokes the create action to the created object
<<create>> <<create>>
: Class
57
D. Destroy Action :A destroy action destroys an object
It tells an object to destroy itself
An object can perform a destroy action on another object, or on itself
In the UML, a destroy action is represented as an arrow with the stereotype <<destroy>> from the object
terminated
<<destroy>>
X
58
E. Send Action
A send action sends a signal to an object
A signal is an asynchronous communication between objects
One object “throws” a signal to another object that “catches” the signal
The sender of the signal does not expect a response from the receiver (unlike the sender of a call action)
Exceptions are the most common type of signals
In the UML, a send action is represented as an arrow with a half arrowhead at the lifeline of the
receiving object
action name
59
Modelling Sequence Diagram
Where is the starting point to built sequence diagrams or collaboration diagrams-
Use-Case and Class Diagrams.
Each use cases in a use-case diagram has its corresponding sequence or collaboration
diagram
You model the diagrams from the main flow of events, or the alternate flow of
events, or the scenarios, of each use case
Every object that you have identified in the sequence or collaboration diagram,
MUST have its corresponding class in the class diagram.
Example: - Modelling a sequence diagram for the log-in use case from the on-line
Bookstore Case Study.
60
Modelling Sequence Diagram --------
The main-flow of events that are involved is: -
1. The CUSTOMER clicks the Log-in button on the Home Page.
2. The system displays the Log-in Page.
3. The CUSTOMER enters his/her user ID and password. The CUSTOMER clicks the OK
button.
4. The system validates the log-in information against the ACCOUNT table in the database.
5. CUSTOMER is an authorised user; the system displays the Personal Home Page to the
CUSTOMER
61
Modelling Sequence Diagram --------
Actors: Customer
Messages and Objects
1. The CUSTOMER clicks the Log-in button on the Home Page.
2. The system displays the Log-in Page.
3. The CUSTOMER enters his/her user ID and password. The CUSTOMER clicks the
OK button.
4. The system validates the log-in information against the ACCOUNT table in the
database.
5. CUSTOMER is an authorised user; the system displays the Personal Home Page to
the CUSTOMER
62
The Customer clicks the
:Customer :HomePage :LoginPage :Account
Login button on the Home
Page clickLogin( )
64 Boundary Object
2. Entity Objects
is an object that contains long-lived information, such as that associated with
databases.
will be mapped to a table (part of the database) in the design phase
It can also contain transient objects, i.e. contents of lists in windows, or
search results.
Entity Object
65
3. Control Objects
is an object that embodies (represents) application logic
Correspond with system actions (not actions taken by actors)
are often used to handle things such as coordination and sequencing
are also useful for calculations involving multiple entity objects
Control Object
will be mapped to codes during implementation phase
used as a connecting tissue between boundary objects and entity objects.
Using the previous example (the log-in use case of the Online Bookstore), we can identify that:
HomePage and Log-in Page objects are boundary objects,
Account object is an entity object.
Therefore, taking this into account, we can draw a new Sequence diagram.
66
1. The Customer clicks the :Customer :HomePage :LoginPage :Account
Login button on the
Home Page clickLogin( )
2. The system displays the
display( )
Login Page
3. The Customer enters his
or her user ID and
enter userID
password, and then clicks
and password
the OK button
4. The system validates the clickOK( )
login information against validateLogin(userID
the persistent Account , password)
data …… and then login OK
returns the Customer to
the Home Page. display( )
.
67 Sequence Diagram
Simple Example
On-line Bookstore is a web application that can be accessed by the store’s registered customer,
whereby each customer can order books, review one or more books sold in the book store, and
sell used books to other customers. Before performing any one of these transactions, the
customer must first log-in into the system using their user id and password kept in their account.
Register
<<extend>>
(CustID) Check out
<<include>>
Sell used books Log-in
<<include>>
72
Order books
verify info
clickProceed( )
display( )
display( )
choose destination
clickOK()
display()
75
confirm and clickOK ()
Use case: Sell used books
Main flow of events: -
1. The CUSTOMER clicks the Sell Used Books button on the
Home Page.
2. The system displays the sell used books web page.
3. The CUSTOMER enters the required information on the
used books that he/she wants to sell.
4.The CUSTOMER clicks the SEND button on the webpage.
5.The system displays a confirmation page listing the
information that the CUSTOMER has entered.
6. The CUSTOMER checks that the information displayed are
accurate. If yes, the CUSTOMER clicks the OK button on
the web page.
7. The system updates the USED BOOKS table in the
database.
Objects:
Home Page, Used Books Page and Confirmation Page: boundary objects
Customer and Used Books: entity objects
76
Sell used books
display( )
verify info
clickOK( )
add( )
add( )
77
Use case: Review
Main flow of events: -
1. The CUSTOMER enters the keyword to search for a book and then
clicks the SEARCH button on the Personal Web Page.
2. The system displays the matching books on the web Page.
3. The CUSTOMER checks for the desired book and clicks
on the chosen book icon.
4. The system displays the book’s detail in the Book Detail
web page.
5. The CUSTOMER clicks the REVIEW button on the web page.
6. The system displays the Review Book web page.
7. The CUSTOMER clicks on the desired star button and the
click the OK button on the web page.
8. The system calculates the overall rating of the book and
updates the Book table in the database.
9. The system displays the Book Detail web pages that have
been updated.
Identify
78
all Objects and Draw the Sequence Diagram for the
above flow of events?
Activity Diagram
79
Activity Modeling
An activity diagram is a behavioral diagram that illustrates the flow of activities or actions within a system or
process.
It is one of the Unified Modeling Language (UML) diagrams used to model the dynamic aspects of a system.
Activity diagrams are particularly useful for modeling business processes, workflows, and system behaviors.
They provide a visual representation of the sequence of actions, decision points, and concurrency within a
process.
Activity diagrams describe the workflow behavior of a system.
They are typically used for modeling:
Business process,
The logic captured by a single use case or usage scenario, or
The detailed logic of a business rule.
UML activity diagrams could potentially model the internal logic of a complex operation. 80
4. Activity Modeling--------
Activity diagrams do not give detail about how objects behave or how objects
collaborate.
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.
Activity diagrams show the sequence of activities in a process, including
sequential and parallel activities.
Symbols are used for activities, decisions and so on.
Arrows represent events that connect the activities.
81
82
4. Activity Modeling--------
The diagram above shows a fork after activity1.
This indicates that both activity2 and activity3 are occurring at the same time.
After activity2 there is a branch.
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.
83
Activity Diagram Symbols
18-84
Example:-Activity of performing selling an item to a
customer.
85
Modeling Activity Diagrams
Ask what happens first, second, and so on.
Determine if the activities happen in sequence or parallel.
Examine all the scenarios for a use case.
Swimlanes
Included on activity diagrams to show partitioning
Show which activities:
Occur on a browser
Occur on a server
Happen on a mainframe
Are done by external partners
18-86
Swimlane Boundaries
18-87
More on Activity Diagrams
Except most transitions are caused by internal events, such as the completion of a
computation.
An activity diagram:
Can be used to understand the flow of work that an object or component performs.
Can also be used to visualize the interrelation and interaction between different use
cases.
Is most often associated with several classes.
89
Representing concurrency
occurred.
The incoming transitions must be triggered in separate threads.
If one incoming transition occurs, a wait condition occurs at the join until
The partition of activities among the existing classes can be explicitly shown using swimlanes.
91
Activity diagrams – an example with swimlanes
92
Note
• Activity diagrams are helpful for visualizing the sequence of steps in a
process, identifying decision points and parallel activities, and
understanding the overall flow of control. They are widely used in
software development, business process modeling, and system
analysis to document and communicate complex processes in a clear
and understandable manner.
93
UI Prototyping
Is an iterative analysis task in which users are actually
participating in mocking up of the UI for a system
Steps
Determine the need (from essential UI model which
was on a paper)
Build the prototype using tools like HLL
Consider the platform (web based – HTML or
Window based – VB)
Evaluate the prototype
By the SME
94