0% found this document useful (0 votes)
21 views213 pages

21-26. OOConcept and UML Diagram

Uploaded by

Rahul Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views213 pages

21-26. OOConcept and UML Diagram

Uploaded by

Rahul Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 213

Software Engineering (CSE3004)

UML Diagrams

Puneet Kumar Jain

CSE Department
National Institute of Technology Rourkela
BASIC OBJECT-ORIENTATION CONCEPTS

2
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Object
 Each object in an object-oriented program usually represents a
tangible real-world entity such as a library member, a book, an
issue register, etc.

 However while solving a problem, it becomes advantageous at


times to consider certain conceptual entities (e.g., a scheduler, a
controller, etc.) as objects as well.

3
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Class
 A class is a description of a set of objects that share the same
attributes, operations, relationships, and semantics.

 Graphically, a class is rendered as a rectangle.

4
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Encapsulation
 Encapsulation is the mechanism that binds together code and the data it
manipulates

 It keeps both safe from outside interference and misuse.

 An object is the device that supports encapsulation. Within an object, code,


data, or both may be private to that object or public.

 Private data may not be accessed by a piece of the program that exists outside
the object.

Ref: https://www.edureka.co/blog/data-hiding-in-cpp/ 5
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Abstraction
 Abstraction
 It is a mechanism of hiding the implementation from the user &
exposing the interface.
 The abstraction mechanism allows us to represent a problem in a
simpler way by considering only those aspects that are relevant to
some purpose and omitting all other details that are irrelevant.

 Feature abstraction: A class hierarchy can be viewed as defining


several levels (hierarchy) of abstraction, where each class is an
abstraction of its subclasses.

 Data abstraction: An object itself can be considered as a data


abstraction entity, because it abstracts out the exact way in which
it stores its various private data items and it merely provides a set
of methods to other objects to access and manipulate these data
items.
6
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Generalization and Inheritance
 Objects are members of classes that define attribute types and
operations.

 Classes may be arranged in a class hierarchy where one class (a


super-class) is a generalisation of one or more other classes (sub-
classes).

 A sub-class inherits the attributes and operations from its super


class and may add new methods or attributes of its own.

 Generalisation in the UML is implemented as inheritance in OO


programming languages.

7
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
A generalization hierarchy
Employee

Mana ger Prog rammer

bu dg etsCon trolled project


prog Lang uages
dateAp po in ted

Project Dept. Strateg ic


Mana ger Mana ger Mana ger

projects dept res po ns ib ilities

8
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Types of Inheritance
 Single Inheritance: A subclass derives from a single super-class.
 Multiple Inheritance: A subclass derives from more than one super-
classes.
 Multilevel Inheritance: A subclass derives from a super-class which in
turn is derived from another class and so on.
 Hybrid Inheritance: A combination of
multiple and multilevel inheritance so
as to form a lattice structure.
 Hierarchical Inheritance: A class has a
number of subclasses each of which
may have subsequent subclasses,
continuing for a number of levels, so
as to form a tree structure.

Img Ref: https://learnbycoding.wordpress.com/2014/11/10/theory-iii/ 9


NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Polymorphism [6]
 Polymorphism
 Polymorphism means "many forms", and it occurs when we
have many classes that are related to each other by
inheritance.
Method overloading
 Compile Time or Early Binding
 Function overloading
 Operator overloading

 Run Time or Late Binding


 Virtual function

10
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Polymorphism [6]
 Run Time or Late Binding
 Virtual function

11
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Relationships
 A relationship is a connection among things.

 In object-oriented modeling, the following important


relationships are
 Dependencies
 Generalizations
 Associations : Aggregation and Composition

 Other relationships are


 Containment
 Persistence

12
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Types of Class Relationships[1]
Relation

Generalization Association Dependency

Binary Association N-ary Association

Aggregation

Composition
13
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Dependency
 A dependency is a using relationship that states that a change in
specification of one thing.

 Graphically, a dependency is rendered as a dashed directed line,


directed to the thing being depended on.

Dependent Class Independent Class

 for example, class Event may affect another thing that uses it (for
example, class Window), but not necessarily the reverse.

14
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Generalizations
 Generalizations connect generalized classes to more-specialized
ones in what is known as subclass/superclass or child/parent
relationships.

 A child inherits the properties of its parents, especially their


attributes and operations.

15
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Association
 An association is a structural relationship that specifies that
objects of one thing are connected to objects of another.
 An association can have a name, and you use that name to
describe the nature of the relationship. So that there is no
ambiguity about its meaning.

 you can give a direction to the name by providing a direction


triangle that points in the direction you intend to read the name.

16
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Aggregation
 Sometimes, you will want to model a "whole/part“ relationship,
in which one class represents a larger thing (the "whole"), which
consists of smaller things (the "parts").

 This kind of relationship is called aggregation, which represents a


"has-a" relationship, meaning that an object of the whole has
objects of the part.

17
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Composition
 Composition means that an object may be a part of only one
composite at a time.

 This is in contrast to simple aggregation, in which a part may be


shared by several wholes.

 In addition, in a composite aggregation, the whole is responsible


for the disposition of its parts, which means that the composite
must manage the creation and destruction of its parts.

18
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Association Types [1]
Car
 aggregation: "is part of"
 Symbolized by empty diamond 1
1 aggregatio
n
Engine
 composition: is made of
 Stronger version of aggregation Book
composition
 The parts live and die with the whole 1

 Symbolized by a filled diamond *


Page

 dependency: Depends on
dependency
 Represented by dotted arrow.
Lottery Random
Ticket

19
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
UML Class Relation Notation Summary [1]

Class Object Object


Generalization Aggregation Composition
Relationship Association Association

1..* 1

0..* 0..*

By default and will always be “1”

dependency
Object Association

n n

20
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Outline
 UML
 Static model
 Dynamic model

 UML Diagrams

 Use case diagram

 Class diagram

21
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Object Modelling: UML
 Object-oriented design (OOD) techniques are now extremely
popular:
 Inception in early 1980’s and nearing maturity.
 Widespread acceptance in industry and academics.
 Unified Modelling Language (UML) became an ISO standard (ISO/IEC 19501)
in 2004.

 UML is language for creating models and it is a modeling language.

• It is not a system design or development methodology

 Used to document object-oriented analysis and design results and independent


of any specific design methodology.

22
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
UML Origin[1]
 OOD in late 1980s and early 1990s:
 Different software development houses were using different
notations.

 UML developed in early 1990s:


 To standardize the large number of object-oriented modelling
notations that existed.

23
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
UML Lineology[1]
 Based Principally on:
 OMT [Rumbaugh 1991]

 Booch’s methodology[Booch 1991]

 OOSE [Jacobson 1992]

 Odell’s methodology[Odell 1992]


OMT
 Shlaer and Mellor [Shlaer 1992]

UML
Booch’s
OOSE Methodology

24
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
UML as A Standard [1]
 Adopted by Object Management Group (OMG) in 1997.

 OMG is an association of industries


 Promotes consensus notations and techniques

 UML also being used outside software development area:


 Example car manufacturing

25
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Developments to UML[1]
 UML continues to develop, due to:
 Refinements
 Making it applicable to new contexts
UML 2.0 2003
Application
to embedded
systems
UML 1.X

UML 1.0 1997

26
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Why are UML Models Required? [1]
 Modelling is an abstraction mechanism:
 Capture only important aspects and ignores the rest.
 Different models obtained when different aspects are ignored.
 An effective mechanism to handle complexity.

 UML is a graphical modelling technique

 Easy to understand and construct

27
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
UML Diagrams[1]
 Nine diagrams in UML1.x :
 Used to capture 5 different views of a system.

 Views: Provide different perspectives of a software system.

 Diagrams can be refined to get the actual implementation of a


system.

28
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Views of a system [1]
 User model view
 This view represents the system (product) from the user’s (called
“actors” in UML) perspective.

 Structural model view


 Data and functionality is viewed from inside the system. That is,
static structure (classes, objects, and relationships) is modeled.
 It is also known as static model

 Behavioral model view


 This part of the analysis model represents the dynamic or behavioral
aspects of the system.
 It is also known as dynamic model

29
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Views of a system[1]
 Implementation model view
 The structural and behavioral aspects of the system are represented
as they are to be built.

 Environment model view


 The structural and behavioral aspects of the environment in which
the system is to be implemented are represented.

30
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Diagrams and views in UML

Structural View Behavioural View


- Class Diagram - Sequence Diagram
- Object Diagram - Collaboration Diagram
- State-chart Diagram
- Activity Diagram

User’s View
-Use Case
Diagram

Implementation View Environmental View


- Component Diagram - Deployment Diagram

31
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
UML[1]
 Class Diagram
 set of classes and their relationships.

 Object Diagram
 set of objects (class instances) and their relationships

 Component Diagram
 logical groupings of elements and their relationships

 Deployment Diagram
 set of computational resources (nodes) that host each
component.

32
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
UML[1]
 Use Case Diagram
 high-level behaviors of the system, user goals, external entities: actors

 Sequence Diagram
 focus on time ordering of messages

 Collaboration Diagram
 focus on structural organization of objects and messages

 State Chart Diagram


 event driven state changes of system

 Activity Diagram
 flow of control between activities

33
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Some Insights on Using UML[1]
 “UML is a large and growing beast, but you don’t need all of it in
every problem you solve…” – Martin Fowler

 “…when learning the UML, you need to be aware that certain


constructs and notations are only helpful in detailed design while
others are useful in requirements analysis …” Brian Henderson-
Sellers

34
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Are All Views Required for Developing A Typical System?
 NO
 For a simple system:
 Use case diagram, class diagram and one of the interaction diagrams
only.

 State chart diagram:


 When class has significant states.
 When states are only one or two, state chart model becomes trivial

 Deployment diagram:
 In case several hardware components used to develop the system.

35
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Static Structure
 Static structure
 key concepts of application, internal structure, relationships

 use case view: use case diagrams

 static view: class diagrams – class, association, generalization,


dependency, realization

 implementation view: component diagram

 Use Case Diagrams – frequently used as the initial step in a


development process
 use case is a scenario
 use case diagram considers scenario as an atomic entity and
merely explains its relationships to the system and the user
 realization of use cases is outside this model element 36
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Dynamic Structure
 Dynamic Behavior
 history of one object as it interacts with its environment, or
communication patterns of sets of objects

 state machine view: state chart diagram


 state, event, transition, action

 activity view: activity diagram

 interaction view: sequence diagram, collaboration diagram

37
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
• Use Case Diagram

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Use Case
 No system exists in isolation.

 Every interesting system interacts with human or automated


actors that use that system for some purpose, and those actors
expect that system to behave in predictable ways.

 A use case specifies the behavior of a system or a part of a system


and is a description of a set of sequences of actions that a system
performs to yield an observable result of value to an actor.

 We can apply use cases to capture the intended behavior of the


system we are developing, without having to specify how that
behavior is implemented.
40
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Use case Diagram: Identification of Use Cases
1. Actor-based:
 Identify the actors related to a system or organization.
 For each actor, identify the processes they initiate or
participate in.

2. Event-based
 Identify the external events that the system must respond to.
 Relate the events to actors and use cases.

43
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Elements of Use Case
1. Actor

2. System or Subject

3. Association or Relationships

4. Business use cases

44
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Elements of Use Case: Actor
 An actor represents a role
that an outsider takes on
when interacting with the
business system.

 Actors can be human or they


can be automated systems.

Img ref: https://en.wikipedia.org/wiki/Use_case_diagram 45


NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Elements of Use Case: System or Subject
 A subject describes a
business system that has
one or more business use
cases attached to it.
 A subject is represented by a
rectangle that surrounds
attached business use cases
and is tagged with a name.

Img ref: https://en.wikipedia.org/wiki/Use_case_diagram 46


NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Elements of Use Case: Association or Relationship
 An association is the
relationship between an
actor and a business use
case.
 It indicates that an actor can
use a certain functionality of
the business system or the
business use case.

Img ref: https://en.wikipedia.org/wiki/Use_case_diagram 47


NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Elements of Use Case: Business Use Case
 Graphically, a use case is
rendered as an ellipse.

 A business use case


describes the interaction
between an actor and a
business system
 It means, it describes the
functionality of the business
system that the actor
utilizes.

 A use case may have variants.

Img ref: https://en.wikipedia.org/wiki/Use_case_diagram 48


NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Use Cases
 Every use case must have a name that distinguishes it from other
use cases.
 A name is a textual string and that name alone is known as a simple
name

 A use case generally placed inside the system boundary and is


always connected to an actor using an association relationship
 A path name is the use case name prefixed by the name of the
package in which that use case lives.

51
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Actors
 Actors are rendered as stick figures.
 You can define general kinds of actors (such as Customer) and
specialize them (such as Commercial Customer) using
generalization relationships.

 Actors may be connected to use


cases only by association.

 An association between an actor


and a use case indicates that the
actor and the use case
communicate with one another

52
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Use Cases and Flow of Events
 A use case describes
 what a system (or a subsystem, class, or interface) does but it does not
specify how it does it.

 We can specify the behavior of a use case


 by describing a flow of events in text clearly enough for an outsider to
understand it easily.

 When we write this flow of events


 We should include how and when the use case starts and ends
 When the use case interacts with the actors and what objects are
exchanged, and the basic flow and alternative flows of the behavior

 For example, in the context of an ATM system


 you might describe the use case to Validate User in the following way:
53
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Use Cases and Flow of Events
 Main flow of events:
 The use case starts when the system prompts the Customer for a PIN
number.
 The Customer can now enter a PIN number via the keypad.
 The Customer commits the entry by pressing the Enter button.
 The system then checks this PIN number to see if it is valid.
 If the PIN number is valid, the system acknowledges the entry, thus ending
the use case.

 Exceptional flow of events:


 The Customer can cancel a transaction at any time by pressing the Cancel
button, thus restarting the use case.
 If the Customer enters an invalid PIN number, the use case restarts.
 If this happens three times in a row, the system cancels the entire
transaction, preventing the Customer from interacting with the ATM for 60
seconds.
54
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Use Cases and Scenarios
 It is desirable to separate main versus alternative flows because a
use case describes
 a set of sequences, not just a single sequence
 it would be impossible to express all the details of an interesting use case
in just one sequence.

 For example, in a human resources system, you might find the use
case Hire employee. This general business function might have
many possible variations.
 You might hire a person from another company
 You might transfer a person from one division to another
 or you might hire a foreign national (which involves its own special rules).
 Each of these variants can be expressed in a different sequence.

55
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Use Cases and Collaborations
 The analysis of a system (which specifies behavior) should, as much as
possible, not be influenced by implementation issues (which specify how that
behavior is to be carried out).

 Ultimately, however, you have to implement your use cases, and can be
created a society of classes and other elements that work together to
implement the behavior of this use case.

 This society of elements, including both its static and dynamic structure, is
modeled in the UML as a collaboration.

 Finding the minimal set of well-structured collaborations that satisfy the flow
of events specified in all the use cases of a system is the focus of a system's
architecture.

56
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Generalization
 Generalization among use cases is just like generalization among
classes.

 Here it means that the child use case inherits the behavior and
meaning of the parent use case

 The child may add to or override the behavior of its parent and
the child may be substituted any place the parent appears
 For example, in a banking system, you might have the use case Validate
User, which is responsible for verifying the identity of the user.
 You might then have two specialized children of this use case
 Check password and Retinal scan where both of which behave just like
Validate User and may be applied anywhere

57
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Include and Extend
 Include Relationship
 An include relationship between use cases means that the
base use case explicitly incorporates the behavior of another
use case at a location specified in the base.

 The included use case never stands alone, but is only


instantiated as part of some larger base that includes it.

 You use an include relationship to avoid describing the same


flow of events several times, by putting the common behavior
in a use case of its own (the use case that is included by a base
use case).

58
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Include and Extend
 Extend Relationship
 An extend relationship between use cases means that the base use
case implicitly incorporates the behavior of another use case at a
location specified indirectly by the extending use case.

 The base use case may stand alone, but under certain conditions, its
behavior may be extended by the behavior of another use case.

 In this way, you separate optional behavior from mandatory


behavior.

 Finally, you may use an extend relationship to model several flows


that may be inserted at a certain point, governed by explicit
interaction with an actor.
59
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Include vs Extend

60
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Generalization, Include, and Extend
 Main flow of events:
 In this example, set priority is an extension point. A use case may have more than one
extension point (which may appear more than once), and these are always matched by
name.
 Under normal circumstances, this base use case will execute without regard for the
priority of the order.
 If this is an instance of a priority order, the extension point (set priority), the behavior
of the extending use case (Place rush order) will be performed, then the flow will
resume.

61
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Constructing Use Case Diagrams [7]
 Collect information sources
 Identify potential actors
 Which partners and customers use the goods and services of the
business system?

 Identify potential business use cases


 Which goods and services can actors draw upon?

 Connect business use cases


 Who can make use of what goods and services of the business
system?

 Describe actors
 Who or what do the actors represent?
62
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Constructing Use Case Diagrams[7]
 Search for more business use cases
 What else needs to be done?

 Edit business use cases


 What actually has to be included in a business use case?

 Document business use cases


 What happens in a business use case?

 Model relationships between business use cases


 What activities are conducted repeatedly?

 Verify the view


 Is everything correct?

63
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Modeling the Behavior of an Element
 Identify the actors that interact with the element.
 Candidate actors include groups that require certain behavior to
perform their tasks.

 Organize actors by identifying general and more specialized roles.


 For each actor, consider the primary ways in which that actor
interacts with the element.

 Consider also the exceptional ways in which each actor interacts with
the element.

 Organize these behaviors as use cases


 Applying include and extend relationships to factor common
behavior and distinguish exceptional behavior.

 Animated Video on use case diagram with example


 https://www.youtube.com/watch?v=zid-MVo7M-E
64
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Text description
 Each ellipse in a use case diagram, by itself conveys very little
information, other than giving a hazy idea about the use case.
 Therefore, every use case diagram should be accompanied by a
text description.
 The text description should define the details of the interaction
between the user and the computer as well as other relevant
aspects of the use case.
 It should include all the behaviour associated with the use case in
terms of the mainline sequence, various alternate sequences, the
system responses associated with the use case, the exceptional
conditions that may occur in the behaviour, etc.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Text description
 Contact persons: This section lists of personnel of the client organisation with
whom the use case was discussed, date and time of the meeting, etc.
 Actors: In addition to identifying the actors, some information about actors using a
use case which may help the implementation of the use case may be recorded.
 Pre-condition: The preconditions would describe the state of the system before
the use case execution starts.
 Post-condition: This captures the state of the system after the use case has
successfully completed.
 Non-functional requirements : This could contain the important constraints for the
design and implementation, such as platform and environment conditions,
qualitative statements, response time requirements, etc.
 Exceptions, error situations: This contains only the domain-related errors such as
lack of user’s access rights, invalid entry in the input fields, etc. Obviously, errors
that are not domain related, such as software errors, need not be discussed here.
 Sample dialogs: These serve as examples illustrating the use case.
 Specific user interface requirements : These contain specific requirements for the
user interface of the use case. For example, it may contain forms to be used, screen
shots, interaction style, etc.
 Document references: This part contains references to specific domain related
documents which may be useful to understand the system operation.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Example
 The use case diagram of the Super market prize scheme

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Example
 The use case diagram of the Super market prize scheme
 U1: register-customer: Using this use case, the customer can register
himself by providing the necessary details.
 Scenario 1: Mainline sequence
 1. Customer: select register customer option
 2 . System: display prompt to enter name, address, and telephone
number.
 3. Customer: enter the necessary values
 4: System: display the generated id and the message that the customer
has successfully been registered.
 Scenario 2: At step 4 of mainline sequence
 4 : System: displays the message that the customer has already
registered.
 Scenario 3: At step 4 of mainline sequence
 4 : System: displays message that some input information have not
been entered. The system displays a prompt to enter the missing
values.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Case Study(Safe Home Security System) [2]
 The SafeHome security function enables the homeowner to configure the security
system when it is installed, monitors all sensors connected to the security system,
and interacts with the homeowner through the Internet, a PC, or a control panel.
 During installation, the SafeHome PC is used to program and configure the system.
Each sensor is assigned a number and type, a master password is programmed for
arming and disarming the system, and telephone number(s) are input for dialing
when a sensor event occurs.
 When a sensor event is recognized, the software invokes an audible alarm attached
to the system. After a delay time that is specified by the homeowner during system
configuration activities, the software dials a telephone number of a monitoring
service, provides information about the location, reporting the nature of the event
that has been detected. The telephone number will be redialed every 20 seconds
until a telephone connection is obtained.
 The homeowner receives security information via a control panel, the PC, or a
browser, collectively called an interface. The interface displays prompting
messages and system status information on the control panel, the PC, or the
browser window. Homeowner interaction takes the following form
69
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Data Flow Diagram

Context-level DFD for SafeHome security function 70


NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Use-Case Diagram [2]
Saf eHome

Access camera
surveillance via t he cameras
Int ernet

Conf igure Saf eHome


syst em paramet ers

homeowner

Set alarm

71
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Use-Case Diagram[2]
Arms/ disarms
syst em

Accesses syst em sensors


via Int ernet

homeow ner

Responds t o
alarm event

Encount ers an
error condit ion

syst em Reconf igures sensors


administ rat or and relat ed
syst em f eat ures

72
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: Use Case Model for Course Management Software [1]
 At the beginning of each semester,
 Each professor shall register the courses that he is going to teach.

 A student can select up to four-course offerings.


 During registration a student can request a course catalogue
showing course offerings for the semester.
 Information about each course such as professor, department and
prerequisites would be displayed.
 The registration system sends information to the billing system, so
that the students can be billed for the semester.

 For each semester, there is a period of time during which dropping of


courses is permitted.

 Professors must be able to access the system to see which students


signed up for each of their course offerings.
73
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: Model Solution [1]
Course Management Software

Register
Course
offering
See
Course
List
Professor Show
registration
<<Extend>>

<<External>>
Register Billing System
course
Student

Drop
Course

Calendar
74
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Style Notes (Ambler, 2005)
 Use case name should begin with a verb.
 While use cases do not explicitly imply timing:
 Order use cases from top to bottom to imply timing -- it improves
readability.
 The primary actors should appear in the left.
 Do not use arrows on the actor-use case relationship.
 To initiate scheduled events include an actor called “time”, or
“calendar”
 Do not show actors interacting with each other.
 <<include>> should rarely nest more than 2 levels deep.
 Use case diagrams represent functionality:
 Should focus on the "what" and not the "how". 75
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Use Case Packaging

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Example: Courseware System Description

77
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: Courseware System Description
 Courseware overview:

78
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: Courseware System Description
 Courseware Actors and Use cases

79
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: Courseware System Description

80
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: Courseware System Description

81
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
• Class Diagram

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Class Diagrams [1]
 A class diagram shows the existence of classes and their relationships in
the logical view of a system
 Represented as solid outline rectangle with compartments.
 Compartments for name, attributes, and operations.

 UML modeling elements in class diagrams


 Classes and their structure and behavior
 Association, aggregation, dependency, and inheritance relationships
 Multiplicity and navigation indicators
 Role names

85
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
UML Class Representation [1]
 A class represents a set of objects having similar attributes,
operations, relationships and behavior.

Class Name

Window
A class can
implicitly
size: Size have a few
Attributes visibility: boolean association
attributes

display()
Operations hide()

86
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Class Based Modeling
 Class-based modeling represents the objects that the
 System will manipulate,

 The operations (also called methods and services) that will be


applied to the objects to effect the manipulation

 Relationship between objects, and

 The collaborations that occur between the classes that are defined.

87
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Class Based Modeling
 Identify and analyze classes by examining the problem statement

 Perform a “grammatical parse” on the use cases developed for


the system to be build.
 Classes are determined by underlining each noun or noun phrase
and entering into a simple table.

 Identify the attributes of each class

 Identify operations that manipulate the attributes

88
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: Identifying Analysis Classes [2]
Safe Home Security System: The Salient features are as follows:
 Safehome security function enables the homeowner to configure the security
system when it is installed, monitors all sensors connected to the security system,
and interacts with the homeowner through the Internet, a PC , or a control panel.
 During installation, the safehome control panel is used to program and configure
the system. Each sensor is assigned a number and type, a master password is
programmed for arming and disarming the system, and telephone number(s) are
input for dialing when a sensor event occurs.
 When a sensor event is recognized, the software invokes an audiable alarm
attached to the system. After a delay time that is specified by the homeowner
during system configuration activities, the software dials a telephone number of a
monitoring service, provides information about the location, reporting the nature
of the events that has been detected.
 The Homeowner receives security information via a control panel, the PC, or a
browser, collectively called an interface. The interface displays prompting
messages and system status information on the control panel, the pc, or the
browser window.
Nouns are underlined
Verbs/activty are italic and bold 90
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Identifying and Analysis Classes
 Selecting Classes—Criteria
 Retained information
 If information about class must be remembered so that the
system can function.
 Needed services
 The potential class must have a set of identifiable operations
that can change the value of its attribute in some way.
 Multiple attributes
 The potential class must have multiple attribute.
 Common attributes
 A set of attributes apply to all instances of the classes.
 Common operations
 A set of operations apply to all instances of the classes.
 Essential requirements
 External entities that appear in the problem space and is
essential to the operation of any solution.
91
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Identifying Analysis Classes
 List of potential SafeHome classes
 Sensor

 Control panel

 System

 Sensor event

 Audible alarm

92
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Identify the attributes of each class
 Attributes describe a class that has been selected for inclusion in
the requirements model.

 To develop a meaningful set of attributes for an analysis class,


study each use case and select those “things” that reasonable
“belong” to the class

93
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example UML classes
 List of attributes for the System class defined for SafeHome
System
 Operations define the behavior of an object.
System
sy stemID
verific ationPhoneNumber
sy stemStatus
delayTime
telephoneNumber
mas terPassw ord
temporaryPass word
attributes numberTries

program()
display()
reset()
query ()
modif y()
operations call()

95
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Class Types[2]
 Entity classes, also called model or business classes, are extracted
directly from the statement of the problem (e.g., FloorPlan and Sensor).

 Boundary classes are used to create the interface (e.g., interactive


screen or printed reports) that the user sees and interacts with as the
software is used.

 Controller classes manage a unit of work from start to finish. That is,
controller classes can be designed to manage
 the creation or update of entity objects;
 the instantiation of boundary objects as they obtain information from
entity objects;
 complex communication between sets of objects;
 validation of data communicated between objects or between the user
and the application.

96
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Relationships
 Relationships provide a pathway for communication between
objects

 Sequence and/or collaboration diagrams are examined to


determine what links between objects need to exist to
accomplish the behavior -- if two objects need to “talk” there
must be a link between them

 Three types of relationships are:


 Association
 Aggregation
 Dependency

100
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Relationships
 An association is a bi-directional connection between classes
 An association is shown as a line connecting the related classes

 An aggregation is a stronger form of relationship where the


relationship is between a whole and its parts
 An aggregation is shown as a line connecting the related classes
with a diamond next to the class representing the whole

 A dependency relationship is a weaker form of relationship


showing a relationship between a client and a supplier where the
client does not have semantic knowledge of the supplier
 A dependency is shown as a dashed line pointing from the client to
the supplier

101
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Relationships
ScheduleAlgorithm
RegistrationForm

RegistrationManager
addStudent(Course, StudentInfo)
Course
name
numberCredits

Student open()
name addStudent(StudentInfo)
major

Professor
name CourseOffering
tenureStatus
location

open()
addStudent(StudentInfo)

102
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Dependency
There are many kinds of dependencies.
 access
 A private import of the contents of another package. It is denoted by
keyword access.
 call
 Statement that a method of one class calls an operation of another
class, keyword is call.
 derivation
 Statement that one instance can be computed from another class,
keyword is derive.
 permission
 Permission for an element to use the contents of another element,
keyword is permit.
DisplayWindow Camera

<<access>>

{passw ord}

107
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Multiplicity and Navigation
 Multiplicity defines how many objects participate in a relationships
 Multiplicity is the number of instances of one class related to ONE
instance of the other class
 For each association and aggregation, there are two multiplicity
decisions to make: one for each end of the relationship

 Although associations and aggregations are bi-directional by default, it


is often desirable to restrict navigation to one direction

 If navigation is restricted, an arrowhead is added to indicate the


direction of the navigation

109
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Multiplicity and Navigation
ScheduleAlgorithm
RegistrationForm

0..* RegistrationManager
1
addStudent(Course, StudentInfo)

1 Course
name
0..* numberCredits

Student open()
addStudent(StudentInfo)
major

1
3..10
1..*
Professor 4
tenureStatus 1 CourseOffering
0..4 location

open()
addStudent(StudentInfo)

110
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Inheritance
 Inheritance is a relationships between a superclass and its subclasses

 There are two ways to find inheritance:


 Generalization
 Specialization
ScheduleAlgorithm
RegistrationForm

RegistrationManager
addStudent(Course, StudentInfo)
Course
name
RegistrationUser numberCredits
name Student open()
addStudent(StudentInfo)
major

Professor
CourseOffering
tenureStatus location

open()
addStudent(StudentInfo)
111
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
CRC Modeling [2]
 Analysis classes have “responsibilities”
 Responsibilities are the attributes and operations encapsulated by the
class

 Analysis classes collaborate with one another


 Collaborators are those classes that are required to provide a class with
the information needed to complete a responsibility.
 In general, a collaboration implies either a request for information or a
request for some action.

CRC: Class Responsibility Collaboration

112
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
CRC Modeling[2]
Class :
Class :
Descri
p tion: :
Class
Descri p tion: :FloorPlan
Class
Descrip tion:
Re sponsibility:
Descrip tion: Collaborator :
Re sponsibility: Collaborator :
Re sponsibility: Collaborator :
Re sponsibility: Collaborator :
defines f loor plan name/type
manages f loor plan positioning
sc ales floor plan f or display
sc ales floor plan f or display
incorporates w alls, doors and window s Wall
show s position of vid eo cameras Camera

A CRC index card for the FloorPlan class


113
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
• Object Diagram

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Object Diagram [4]
 It contains image of objects while an image of a system is a
diagram of a snapshot at a point in time.

 An object diagram is not restricted to specific objects while it may


also include value specifications of objects.

 Snapshots are examples of systems, not definitions of systems.

 Triangle is an object of class Polygon where triangle has three


points

116
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Object Diagram [4]
object name object
Triangle: Polygon

Partof Partof Partof link

point1:Point point2:Point point3:Point

X=0.0 X=3.0 X=3.0


Y=1.0 Y=1.0 Y=5.0

117
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Object Diagram [1]
LibraryMember
LibraryMember LibraryMember
Mritunjay
B10028 Mritunjay
C-108, Laksmikant Hall B10028
1119 C-108, Laksmikant Hall
Mrituj@cse 1119
25-02-04 Mrituj@cse
25-03-06 25-02-04
NIL 25-03-06
NIL
IssueBook( );
findPendingBooks( );
findOverdueBooks( );
returnBook( );
findMembershipDetails( );

Different representations of
the LibraryMember object
118
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
• Dynamic Model

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Dynamic Model
 Sequence Diagram
 State Diagram
 Activity Diagram

 UML Extensibility
 https://www.visual-paradigm.com/guide/uml-unified-modeling-
language/uml-extexsibility-mechanism/

 UML meta model


 http://www.cs.sjsu.edu/faculty/pearce/modules/lectures/uml2/ind
ex.htm

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Dynamic Model
 Dynamic model describes those aspects of the system that
changes with the time.

 It is used to specify and implement control aspects of the system.

 It depicts states, transitions, events and actions

 The dynamic model includes


 event trace diagrams describing scenarios
 a scenario is a sequence of events that occurs during one
particular execution of a system

124
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
• Interaction Diagram

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Interaction Diagrams [1]
 A series of diagrams describing the dynamic behavior of an
object-oriented system.
 A set of messages exchanged among a set of objects within a
context to accomplish a purpose.

 The interactions are represented by sequence diagram therefore


sequence diagram is one type of interaction diagram.

127
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Interaction Diagrams (Cont.) [1]
 The purpose of Interaction diagrams is to:
 Model interactions between objects
 Assist in understanding how a system (a use case) actually
works
 Verify that a use case description can be supported by the
existing classes
 Identify responsibilities/operations and assign them to classes

 Interaction Diagram
 Sequence diagram
 Collaboration diagram

128
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
A First Look at Sequence Diagrams[1]
 Captures how objects interact with each other:
 To realize some behavior (use case execution).
 Emphasizes time ordering of messages.
 Can model: Simple sequential flow, branching, iteration, recursion, and
concurrency.
X-Axis (objects)
member: :Book
book:Book
LibraryMember Copy
Y-Axis (time)

borrow(book) Life Line


Object
ok = canBorrow()

message
Activation box
[ok] borrow(member)
setTaken(member)

condition
How do you show Mutually exclusive conditional messages?
129
129
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Develop One Sequence diagram for every use case[1]

Return
Book member: :Book
book:Book
LibraryMember Copy

Use ok = canBorrow()
Case borrow(book)

Borrow
Book
Book [ok] borrow(member)

setTaken(member)
Search
Book

130
130
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Elements of Sequence Diagram: dimension
 Object Dimension: The horizontal axis shows the elements that are
involved in the interaction
 Conventionally, the objects involved in the operation are listed from
left to right according to when they take part in the message
sequence. However, the elements on the horizontal axis may appear
in any order
 Time Dimension: The vertical axis represents time proceedings (or
progressing) down the page. X-Axis (objects)

member: :Book
Y-Axis (time)

book:Book
LibraryMember Copy

borrow(book) Object
Life Line
ok = canBorrow()
message
Activation box
[ok] borrow(member)
setTaken(member)

condition
How do you show Mutually exclusive conditional messages?

Ref: https://www.youtube.com/watch?v=_Mzi1rYtI5U 131


NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Elements of Sequence Diagram: Actor
 An actor in a UML diagram represents a type of role where it
interacts with the system and its objects.
For example – Here the user in seat reservation system is
shown as an actor where it exists outside the system and is
not a part of the system.

Ref:https://www.geeksforgeeks.org/unified-modeling-language-uml-sequence-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Elements of Sequence Diagram: Lifeline
 Lifelines – A lifeline is a named element which depicts an
individual participant in a sequence diagram
 The standard in UML for naming a lifeline follows the following
format – Instance Name : Class Name

Ref:https://www.geeksforgeeks.org/unified-modeling-language-uml-sequence-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Elements of Sequence Diagram: Activation
 Activations: A thin rectangle on a lifeline represents the period
during which an element is performing an operation.
 The top and the bottom of the of the rectangle are aligned with
the initiation and the completion time respectively

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-sequence-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Elements of Sequence Diagram: Messages
 Messages – Communication between objects is depicted using
messages. The messages appear in a sequential order on the
lifeline. We represent messages using arrows.

Ref:https://www.geeksforgeeks.org/unified-modeling-language-uml-sequence-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Types of messages
 Synchronous messages – A synchronous message waits for a
reply before the interaction can move forward. The caller
continues only when it knows that the receiver has processed the
previous message i.e. it receives a reply message.
 We use a solid arrow head to represent a synchronous message.

Snapshots are examples of systems, not


definitions of systems.

Ref:https://www.geeksforgeeks.org/unified-modeling-language-uml-sequence-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Types of messages
 Reply Message – Reply messages are used to show the message
being sent from the receiver to the sender.
 We represent a return/reply message using an open arrowhead
with a dotted line.
 For example – Consider the scenario where the device requests a
photo from the user. Here the message which shows the photo
being sent is a reply message.

Ref:https://www.geeksforgeeks.org/unified-modeling-language-uml-sequence-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Types of messages
 Create message – We use a Create message to instantiate a new
object in the sequence diagram.
 It is represented with a dotted arrow and create word labelled on
it to specify that it is the create Message symbol.
 For example – The creation of a new order on a e-commerce
website would require a new object of Order class to be created.

Ref:https://www.geeksforgeeks.org/unified-modeling-language-uml-sequence-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Types of messages
 Delete Message – We use a Delete Message to delete an object.
When an object is deallocated memory or is destroyed within the
system we use the Delete Message symbol.
 It is represented by an arrow terminating with a x.
 For example – In the scenario below when the order is received
by the user, the object of order class can be destroyed.

Ref:https://www.geeksforgeeks.org/unified-modeling-language-uml-sequence-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Types of messages
 Self Message – Certain scenarios might arise where the object
needs to send a message to itself. Such messages are called Self
Messages and are represented with a U shaped arrow.
 For example – Consider a scenario where the device wants to
access its webcam.
Recursive Message represents
the invocation of message of the
same lifeline.

Ref:https://www.geeksforgeeks.org/unified-modeling-language-uml-sequence-diagrams/
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-sequence-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Types of messages
 Found Message – A Found message is used to represent a
scenario where an unknown source sends the message.
 It is represented using an arrow directed towards a lifeline from
an end point.
 For example: Consider the scenario of a hardware failure.

Ref:https://www.geeksforgeeks.org/unified-modeling-language-uml-sequence-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Types of messages
 Lost Message – A Lost message is used to represent a scenario
where the recipient is not known to the system.
 It is represented using an arrow directed towards an end point
from a lifeline.
 For example: Consider a scenario where a warning is generated.
 Since the destination is not known before hand, we use the Lost
Message symbol.

Ref:https://www.geeksforgeeks.org/unified-modeling-language-uml-sequence-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Types of messages
 Guards – To model conditions we use guards in UML.
 They are used when we need to restrict the flow of messages on
the pretext of a condition being met.
 Example: In order to be able to withdraw cash, having a balance
greater than zero is a condition that must be met as shown below.

Ref:https://www.geeksforgeeks.org/unified-modeling-language-uml-sequence-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: travel portal[1]
 A user can use a travel portal to plan a travel
 When the user presses the plan button, a travel agent applet
appears in his window
 Once the user enters the source and destination,
 The travel agent applet computes the route and displays the itinerary.
 Travel agent widget disappears when user presses close button

:client

plan <<create>> :travelAgent

setItinerary
calculateRoute

<<destroy>>
145
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Syntax used in Sequence Diagram[1]
 Conditional Message
 [ variable = value ] message()
 Message is sent only if clause evaluates to true

 Iteration (Looping)
 * [ i := 1..N ] message()
 “*” is required; [ ... ] clause is optional
 The message is sent many times to possibly multiple receiver
objects.

 UML2 uses a new notation called interaction frames to


support these

146
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Sequence Diagrams[1]
How to represent Mutually exclusive conditional invocations? If book is
available, invoke msg2 on ClassB else invoke msg3 on classC,

:ClassA :ClassB :ClassC

msg1( )
flag = checkBook()

[flag = true] msg2( )

[flag = false] msg3( )

147
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Elements of Sequence Diagram: Sequence Fragments
 UML 2.0 introduces sequence (or interaction) fragments.
Sequence fragments make it easier to create and maintain
accurate sequence diagrams
 A sequence fragment is represented as a box, called a combined
fragment, which encloses a portion of the interactions within a
sequence diagram
 The fragment operator (in the top left cornet) indicates the type
of fragment
 Fragment types: ref, assert, loop, break, alt, opt, neg

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-sequence-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Elements of Sequence Diagram: Sequence Fragments
Operator Fragment Type
Alternative multiple fragments: only the one whose
alt
condition is true will execute.
Optional: the fragment executes only if the
opt supplied condition is true. Equivalent to an alt only
with one trace.
par Parallel: each fragment is run in parallel.
Loop: the fragment may execute multiple times,
loop
and the guard indicates the basis of iteration.
Critical region: the fragment can have only one
region
thread executing it at once.
Negative: the fragment shows an invalid
neg
interaction.
Reference: refers to an interaction defined on
another diagram. The frame is drawn to cover the
ref
lifelines involved in the interaction. You can define
parameters and a return value.
Sequence diagram: used to surround an entire
sd
sequence diagram.
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-sequence-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Elements of Sequence Diagram: Sequence Fragments

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-sequence-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: Hotel System
 Below is a sequence diagram for making a hotel reservation. The object
initiating the sequence of messages is a Reservation window.

3. Reservation confirmed

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-sequence-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: search book

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-sequence-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
• Collaboration Diagram

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Collaboration diagram
 COLLABORATION DIAGRAM depicts the relationships and interactions
among software objects.
 They are also known as “Communication Diagrams.”
 They are used to understand the object architecture within a system
rather than the flow of a message as in a sequence diagram.
 It allows you to focus on the elements rather than focusing on the
message flow as described in the sequence diagram.
 Its syntax is similar to that of sequence diagram except that lifeline
don't have tails.
 Messages passed over sequencing is indicated by numbering each
message hierarchically.
 Sequence diagrams can be easily converted into a collaboration diagram
as collaboration diagrams are not very expressive.
https://www.guru99.com/interaction-collaboration-sequence-diagrams-examples.html
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Collaboration Diagram for the renew book use case[1]
:Book
6: * find

9: update
:Library
:Library
:Library :Library
:Library Boundary
Book
Renewal
Book :Book Member
Register
Book Controller
[reserved] Register
renewBook find MemberBorrowing
displayBorrowing

8: apology 10:
5: book selectBooks
bookSelected
confirm
Selected [reserved]
* find

[reserved] apology
[reserved]
1: renewBook update
:Library 7: apology
apology

:Library Book
Boundary 3: display Renewal confirm

Borrowing Controller
confirm
updateMemberBorrowing

4: selectBooks
2: findMemberBorrowing

12: confirm
:Library
updateMemberBorrowing
Member
155
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
• State Diagram

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


What is a State?
 Rumbaugh defines that:
"A state is an abstraction of the attribute values and links of an object.
Sets of values are grouped together into a state according to properties
that affect the gross behavior of the object."

 A state is a constraint or a situation in the life cycle of an object,


in which a constraint holds, the object executes an activity or
waits for an event.

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-state-machine-diagram/ 158
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Stateless vs. Stateful Objects[1]
 State-independent (modeless):
 Type of objects that always respond the same way to an event.

 State-dependent (modal):
 Type of objects that react differently to events depending on its state or
mode.
 Use state machine diagrams for modeling objects with complex state-
dependent behavior.

159
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Stateful Classes[1]
 Examples of some classes that have non-trivial state models:
 Lift controller: Up, down, standstill
 Game software controller: Novice, Moderate, Advanced…
 GUI: Active, Inactive, clicked once, …
 Robot controller: Obstacle, clear, difficult terrain…

160
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Robot: State Variables[1]
 Movement: On, OFF
How many states in the
 Direction: Forward, Backward, state machine model?
left, Right
 Left hand: Raised, Down
 Right hand: Raised, down
 Head: Straight, turned left, turned right
 Headlight: On, Off
 Turn: Left, Right, Straight

FSM: exponential rise


in number of states
with state variables
UML Dynamic Model 161
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
State Diagram for Event-Based Programming[1]
 Traditional programs have single flow of control
 Represented using flowchart or activity diagram

 Event-driven systems :
 In contrast, depending on an event occurrence, corresponding handler is
activated
 Programming these using traditional approach often not suitable, and
would at the least cause wasteful computations.
 Represented using state machines.

162
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
State Chart Diagram Cont…
 State chart avoids two problems of FSM:
 State explosion
 Lack of support for representing concurrency

163
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Difference between state diagram and flowchart
 The basic purpose of a state diagram is to portray various
changes in state of the class and not the processes or commands
causing the changes.
 However, a flowchart on the other hand portrays the processes
or commands that on execution change the state of class or an
object of the class.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


State Machine Diagram[4]
 A state machine models the possible life histories of an object of
a class.
 A state machine contains states connected by transitions.
 Each state models a period of time during the life of an object
during which it satisfies certain conditions.

 When an event occurs, it may cause the firing of a transition that


takes the object to a new state.
 When a transition fires, an effect (action or activity) attached to the
transition may be executed.
 State machines are shown as state machine diagrams.

165
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
State Machine Diagram[4]
 A state machine is a graph of states and transitions.
 Usually a state machine is attached to a class and describes the
response of an instance of the class to events that it receives.
 State machines may also be attached to behaviors, use cases, and
collaborations to describe their execution.
 Example of state machine diagram that shows
 the history of a ticket to a performance.

166
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
State Machine Diagram[4]
 Event
 Any external influence from the rest of the world is summarized as an
event.
 When the object detects an event, it responds in a way that depends on its
current state.

 The response may include the execution of an effect and a change


to a new state.

 A state machine is a localized view of an object


 a view that separates it from the rest of the world
 and examines its behavior in isolation

167
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Basic components of a statechart diagram
 State – We use a rounded rectangle to represent a state. A state
represents the conditions or circumstances of an object of a class
at an instant of time.

 Initial state – We use a black filled circle represent the initial state
of a System or a class.

 Final state – We use a filled circle within a circle notation to


represent the final state in a state machine diagram.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Composite state
 We use a rounded rectangle to represent a composite state also.

 A composite state is one that has been decomposed into regions


 each of which contains one or more direct sub-states.

 A decomposition of a non-orthogonal state into direct sub-states


is similar to specialization of a class, each of which inherits the
transitions of the outer state.

 Only one direct sub-state per non-orthogonal state can be active


at one time.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


How to Use Super-State / Sub-State for Toaster
 We can partition working and idle as state and encapsulate the
detailed state inside each of them. The transition will be made
between working and ideal state:

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/about-state-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Substates
 A state which has substates (nested states) is called a composite
state.
 Substates may be nested to any level.
 A nested state machine may have at most one initial state and
one final state.
 Substates are used to simplify complex flat state machines by
showing that some states are only possible within a particular
context (the enclosing state).

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-state-machine-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Concurrent Sub-States and Regions
 Concurrent Sub-states are independent and can complete at
different times and each sub-state is separated from the others
by a dashed line

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/about-state-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Concurrent State
 The following state machine diagram models an auction with two
concurrent substates: processing the bid and authorizing the
payment limit.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


History States
 Unless otherwise specified, when a transition enters a composite
state, the action of the nested state machine starts over again at
the initial state (unless the transition targets a sub-state directly).

 History states allow the state machine to re-enter the last sub-
state that was active prior to leaving the composite state.

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/about-state-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Basic components of a statechart diagram
 Transition – We use a solid arrow to represent the transition or
change of control from one state to another. The arrow is labelled
with the event which causes the change in state.

 Self transition – We use a solid arrow pointing back to the state


itself to represent a self transition. There might be scenarios
when the state of the object does not change upon the
occurrence of an event. We use self transitions to represent such
cases.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Transition[4]
 External transition.
 An external transition is transition that changes the active state.
 This is the most common kind of transition
 It is drawn as an arrow from the source state to the target state

 Properties of External Transition


 Trigger Event
 The trigger specifies the event that enables a transition
 The event may have parameters which are available to an effect
specified as part of the transition

 Guard Condition
 A transition may have Boolean expression called guard condition
 It may reference attributes of the object that owns the state
machine and parameters of the trigger event
177
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: External Transition[4]

178
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Basic components of a statechart diagram

 Fork – We use the fork notation to


represent a state splitting into two or
more concurrent states.

 Join – We use the join notation when


two or more states concurrently
converge into one on the occurrence of
an event or events.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


EVENTS[4]
 Signal : sname(a:T)
 A signal is kind of classifier that is explicitly intended as a communication
vehicle between two objects, asynchronous communication among objects

 Call event: op(a:T)


 A call event is the reception of a synchronous call of an operation by an
object.
 The receiving class chooses whether an operation will be implemented as a
method or a call event that is triggered in a state machine (or possibly
both).
 Change event: when(exp)
 A change event is the satisfaction of a Boolean expression that depends on
designated attribute values.
 This is a declarative way to wait until a condition is satisfied

 Time event: after(time)


 Time events represent the passage of time.
 A time event can be specified either in absolute mode (time of day) or
relative mode (time elapsed since a given event).
180
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: temperature controller

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/about-state-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Steps to draw a state diagram –
 Identify the initial state and the final terminating states.

 Identify the possible states in which the object can exist


(boundary values corresponding to different attributes guide us in
identifying different states).

 Label the events which trigger these transitions.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Example: Ticket-selling Machine[4]

184
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: GUI Accepts only Balanced Parentheses [1]
 Inputs are any characters
 No nesting of parentheses
 No “output” other than any state change

(
Balanced Not
start Balanced
end )
* *

186
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: GUI Accepts only upto 3 Nested parentheses[1]
 How can we extend this machine to handle arbitrarily deep
nesting of parentheses?

end
( ( (

OK Wait 1 Wait 2 Wait 3


start
) ) )
) * * * (
*
Error

*
187
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
How to Model Nested parentheses?[1]
 A state machine, but not just a state machine --- an EFSM

(/count++
(/count=1

start OK Wait

)[count==1] /count=0
end )[count>1]/ count--

188
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Developing State-charts from Use Cases[1]
 Collect the actions, conditions and results from a use case
description.

 Develop a preliminary state-chart with those actions and


conditions as the events, the results and the states.

 Consider any alternative external events not in the use case.

 Refine into hierarchical and concurrent state-charts.

190
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Assignment
 Draw the state chart diagram of an elevator.

 The elevator is by default at the ground floor.

 It moves up when an up button is pressed and halts when the


required floor is reached.

 When a button at a lower floor is pressed:


 It moves down and halts when the required floor is reached.

 When it is inactive at a floor for more than 10 minutes:


 It moves down to the ground floor.

191
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
• Activity Diagram

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Difference between Use case diagram and Activity diagram
 An activity diagram is used to model the
workflow depicting conditions,
constraints, sequential and concurrent
activities.

 On the other hand, the purpose of a


Use Case is to just depict the
functionality i.e. what the system does
and not how it is done.

 So in simple terms, an activity diagram


shows ‘How’
 while a Use case shows ‘What’ for a
particular system.
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Activity Diagram[1]
 Not present in earlier modelling techniques:
 Possibly based on event diagram of Odell [1992]

 Often used to represent processing steps in a single or a group of


use cases:
 May not correspond to methods

 An activity is a state with an internal action and has one or more


outgoing transitions, e.g. fillOrder.

 Vague similarity exists with a flowchart

 Carried out during requirements analysis and specification stage.

 Useful in developing interaction diagrams and test cases.


198
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Activity Diagram [4]
 An activity is a graph of nodes and flows that shows the flow of
control (and optionally data) through the steps of a computation.

 Execution of steps can be both concurrent and sequential.

 An activity involves both synchronization and branching constructs


 similar to traditional flow chart
 but more powerful than it which only supports sequential and
branching constructs
 an activity definition contains activity nodes

199
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Activity Diagram
 We use Activity Diagrams to illustrate the flow of control in a
system and refer to the steps involved in the execution of a use
case.

 We describe or depict what causes a particular event using an


activity diagram.

 An activity diagram portrays the control flow from a start point to


a finish point showing the various decision paths that exist while
the activity is being executed.

https://www.geeksforgeeks.org/unified-modeling-language-uml-activity-diagrams/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Difference between Activity diagram and Flowchart
 Flowcharts were typically invented earlier than activity diagrams.
Non programmers use Flow charts to model workflows.
 For example: A manufacturer uses a flow chart to explain and
illustrate how a particular product is manufactured.

 Programmers use activity diagrams (advanced version of a


flowchart) to depict workflows. An activity diagram is used by
developers to understand the flow of programs on a high level.

 We can call a flowchart a primitive version of an activity diagram.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Activity Diagram Notations
 Initial State: The starting state before an activity takes place is
depicted using the initial state.

 Final State or End State The state which the system reaches when
a particular process or activity ends is known as a Final State or
End State. We use a filled circle within a circle notation to
represent the final state in a state machine diagram. A system or a
process can have multiple final states.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Activity Diagram[4]
 Action or Activity State: We represent an activity using a
rectangle with rounded corners.

 Activity Node
 It represents the execution of a statement in a procedure or the
performance of a step in a workflow
 Basically any action or event that takes place is represented using an
activity

 Activity nodes may be nested.


203
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Activity Diagram Notations
 Action Flow or Control flows – Action flows or Control flows are
also referred to as paths and edges. They are used to show the
transition from one activity state to another.

 An activity state can have multiple incoming and outgoing action


flows.

 Consider the example – Here both the states transit into one final
state using action flow symbols i.e. arrows.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Activity Diagram Notations
 Decision node and Branching – When we need to make a
decision before deciding the flow of control, we use the decision
node.

 Guards – A Guard refers to a statement written next to a decision


node on an arrow sometimes within square brackets.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Activity Diagram Notations
 Fork – Fork nodes are used to support
concurrent activities.

 When we use a fork node when both


the activities get executed concurrently
i.e. no decision is made before splitting
the activity into two parts.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Activity Diagram Notations
 Join – Join nodes are used to support
concurrent activities converging into one.
For join notations we have two or more
incoming edges and one outgoing edge.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Activity Diagram Notations
 Merge or Merge Event –
Scenarios arise when activities
which are not being executed
concurrently have to be merged.
We use the merge notation for
such scenarios. We can merge
two or more activities into one if
the control proceeds onto the
next activity irrespective of the
path chosen.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Activity Diagram Notations
 We use swimlanes (Partitions) for grouping related activities in
one column.
 Swimlanes group related activities into one column or one row.
 Swimlanes can be vertical and horizontal.
 Swimlanes are used to add modularity to the activity diagram. It is
not mandatory to use swimlanes.
 It’s similar to creating a function in a program. It’s not mandatory
to do so, but, it is a recommended practice.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Activity Diagram Notations
 For example – Here different set of activities are executed based
on if the number is odd or even. These activities are grouped into
a swimlane.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Activity Diagram Notations
 Example: A swimlane is also a way to group activities performed
by the same actor on an activity diagram or to group activities in a
single thread.

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Partitions and Object Flows[4]

212
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Activity Diagram Notations
 Time Event :We can have a scenario where an event takes some
time to complete.


For example – Let us assume that the processing of an image
takes a lot of time. Then it can be represented as shown below.

213
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Use Case Diagram [4]

214
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: Processing an Order by the Box Office[4]

215
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: Enrollment in the University

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Example: Processing of an Order [1]
[order reject]

Receive Fill Close


Ship
Order Order Order
Order
[order
accept]

Send
Make Accept
Invoice Invoice Payment Payment

217
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: student admission process at IIT [1]
Academic Section Accounts Section Hostel Office Hospital Department
check
student
records
receive
fees

allot create
hostel hospital
record
register
receive
in
fees
course
conduct
allot medical
room examination

issue
identity card

218
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Uses and Abuses of Activity Diagrams[1]
 Activity diagrams are useful to show behavior that spans over
multiple use cases:
 Describe the workflow of the overall process.

 For multiple objects and their high-level interaction,


 Activity diagrams are particularly helpful for representing an
overview of concurrent processes

 Activity diagrams are not accurate for describing how an object


behaves over its lifetime.

 Use a state machine diagram instead.

219
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
• Deployment Diagram

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


When to Use Deployment Diagram?
 What existing systems will the newly added system need to
interact or integrate with?
 How robust does system need to be (e.g., redundant hardware in
case of a system failure)?
 What middleware, including the operating system and
communications approaches and protocols, will system use?
 What hardware and software will users directly interact with (PCs,
network computers, browsers, etc.)?
 How will you monitor the system once deployed?
 How secure does the system needs to be (needs a firewall,
physically secure hardware, etc.)?
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-deployment-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Purpose of Deployment Diagrams
 They show the structure of the run-time system

 They capture the hardware that will be used to implement the


system and the links between different items of hardware.

 They model physical hardware elements and the communication


paths between them

 They can be used to plan the architecture of a system.

 They are also useful for Document the deployment of software


components or nodes

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-deployment-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Deployment Diagram elements
 Graphically, a deployment diagram is a collection of vertices and
arcs.
 Deployment diagrams commonly contain:
 Nodes: 3-D box represents a node, either software or hardware
 HW node can be signified with <<stereotype>>
 Connections between nodes are represented with a line, with
optional <<stereotype>>
 Nodes can reside within a node

 Other Notations
 Dependency
 Association relationships.
 May also contain notes and constraints.

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-deployment-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: Deployment Diagram

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-deployment-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: deployment Diagram

https://www.tutorialspoint.com/uml/uml_deployment_diagram.htm
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
• Component Diagram

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


Component diagram
 Component diagrams are used in modeling the physical aspects of
object-oriented systems that are used for visualizing, specifying,
and documenting component-based systems and also for
constructing executable systems through forward and reverse
engineering.

 Component diagrams are essentially class diagrams that focus on


a system's components that often used to model the static
implementation view of a system.

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-component-diagram/ 227
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Component Diagram at a Glance
 A component diagram breaks down the actual system under
development into various high levels of functionality.

 Each component is responsible for one clear aim within the entire
system and only interacts with other essential elements on a
need-to-know basis.

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-component-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Basic Concepts of Component Diagram
 A component represents a modular part of a system that
encapsulates its contents and whose manifestation is replaceable
within its environment.

 In UML 2, a component is drawn as a rectangle with optional


compartments stacked vertically.

 A high-level, abstracted view of a component in UML 2 can be


modeled as:
 A rectangle with the component's name
 A rectangle with the component icon
 A rectangle with the stereotype text and/or icon

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-component-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Basic Concepts of Component Diagram
 Interface: In the example below shows two type of component
interfaces:
 Provided interface symbols with a complete circle at their end
represent an interface that the component provides - this "lollipop"
symbol is shorthand for a realization relationship of an interface
classifier.
 Required Interface symbols with only a half circle at their end (a.k.a.
sockets) represent an interface that the component requires (in
both cases, the interface's name is placed near the interface symbol
itself).

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-component-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Basic Concepts of Component Diagram
 Port: Ports are represented using a square along the edge of the
system or a component. A port is often used to help expose
required and provided interfaces of a component.

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-component-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Relationships
 Association: An association specifies a semantic relationship that can occur
between typed instances.

 Aggregation: A kind of association that has one of its end marked shared as
kind of aggregation, meaning that it has a shared aggregation.

 Composition: a strong form of aggregation that requires a part instance be


included in at most one composite at a time

 Constraint: A condition or restriction expressed in natural language text or in a


machine readable language for the purpose of declaring some of the
semantics of an element.

 Dependency: a single or a set of model elements requires other model


elements for their specification or implementation

 Links: A generalization is a taxonomic relationship between a more general


classifier and a more specific classifier.
https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-component-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Basic Concepts of Component Diagram
 Subsystems: The subsystem classifier is a specialized version of a
component classifier.
 Because of this, the subsystem notation element inherits all the
same rules as the component notation element.
 The only difference is that a subsystem notation element has the
keyword of subsystem instead of component.

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-component-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example
 The example shows the internal components of a larger component:
 The data (account and inspection ID) flows into the component via the port on
the right-hand side and is converted into a format the internal components can
use. The interfaces on the right are known as required interfaces, which
represents the services the component needed in order to carry out its duty.

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-component-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example
 The data then passes through several components via connections before it is
output at the ports on left. Those interfaces are known as provided interface,
which represents the services to deliver by the exhibiting component.
 It is important to note that the internal components are surrounded by a large
'box' which can be the overall system itself or a subsystem or component of
the overall system (in this case the 'box' is a component itself).

https://www.visual-paradigm.com/guide/uml-unified-modeling-language/what-is-component-diagram/
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
• UML Extensibility

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”


UML Extensibility
 UML provides several extension mechanisms to allow modelers to make
some common extensions without having to modify the underlying
modeling language.

 It allows to extend the language in controlled ways.

 UML defines three extensibility mechanisms to allow modelers to add


extensions without having to modify the underlying modeling language.

 These three mechanisms are:


 Stereotypes
 Constraints
 tagged values

238
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Profile [4]
 Extensions are organized into profiles.

 A profile is coherent set of extensions applicable to a given


domain or purpose.

 A profile is a package that identifies a subset of an existing base


meta-model

 It defines stereotypes and constraints that may be applied to the


selected meta model subset.

 Extensions to UML is shown with an example.

239
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
Example: Profile [4]

240
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
UML Extensibility: Stereotypes [4]
 A stereotype is a kind of model element defined in the model itself.

 A stereotype extends the vocabulary of the UML


 Allowing you to create new kinds of building blocks that are derived from
existing ones but that are specific to your problem
 They are used for classifying or marking the UML building blocks in order
to introduce new building blocks

 In defining a stereotype, each tag is a name of some property that we


(modeler) want to record.

241
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
UML Extensibility: Tagged values[6]
 A tagged value extends the properties of a UML building block, allowing you to
create new information in that element’s specification

 They are properties for specifying keyword-value pairs of model elements,


where the keywords are attributes

 They allow you to extend the properties of a UML building block so that you
create new information in the specification of that element

242
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
UML Extensibility: Constraint[6]
 A constraint is an extension of the semantics of a UML element,
allowing you to add new rules or to modify existing ones
 They allow you to extend the semantics of a UML building block by adding
new rules or modifying existing ones
 A constraint specifies conditions that must be held true for the model to be
well-formed.

 UML provides several extension mechanisms that allow you to do


this without having to modify the underlying modeling language.

 These mechanisms add new building blocks, modify the


properties of existing ones and even change their semantics.

243
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
References
1. Rajib Mall, “Fundamentals of Software Engineering”, 3rd edition, PHI, 2009
2. R.S. Pressman, “Software Engineering: A Practitioner's Approach”, 7th Edition,
McGraw
3. Sommerville, “ Introduction to Software Engineering”, 8th Edition, Addison-
Wesley, 2007
4. GRADY BOOCH, JAMES RUMBAUGH, IVAR JACOBSON, The Unified Modeling
Language User Guide, Addison Wesley, Reading, Massachusetts, May 2005
5. Pankaj Jalote, “An Integrated Approach to Software Engineering” Third
addition , Springer Press
6. Patrick Grässle, Henriette Baumann, and Philippe Baumann, “UML 2.0 in
Action A Project-Based Tutorial”, PACKT Publishing, Birmingham, UK, 2005.
7. https://www.visual-paradigm.com/guide/uml-unified-modeling-
language/uml-extexsibility-mechanism
8. http://www.cs.sjsu.edu/faculty/pearce/modules/lectures/uml2/index.htm
9. https://www.uml-diagrams.org/examples/online-shopping-domain-uml-
diagram-example.html

251
NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”
• End of Chapter

NIT Rourkela Puneet Kumar Jain “Software Engineering (CSE3004)”

You might also like