Unit 1 Chapter 3
Unit 1 Chapter 3
Unit 1 Chapter 3
UNIT-1
Chapter-3 (Function and Object oriented design)
Structured analysis, Data flow diagrams, Basic object orientation concepts, Unified
modeling language, Use case model, Class diagrams, Interaction diagrams,
Activity diagrams, State chart diagrams.
Chapter-3
(Function Oriented Software Design)
Or
Generic Procedure
Start with a high-level description of what the software/program does. Refine each
part of the description by specifying in greater detail the functionality of each part.
These points lead to a Top-Down Structure.
1. Data Flow Diagram (DFD): A data flow diagram (DFD) maps out the flow
of information for any process or system. It uses defined symbols like
rectangles, circles and arrows, plus short text labels, to show data inputs,
outputs, storage points and the routes between each destination.
As the name itself implies, SA/SD methodology involves carrying out two distinct
activities:
The roles of structured analysis (SA) and structured design (SD) have been shown
schematically in Figure. Observe the following from the figure:
As shown in Figure 6.1, the structured analysis activity transforms the SRS
document into a graphic model called the DFD model. During structured analysis,
functional decomposition of the system is achieved. That is, each function that
the system needs to perform is analysed and hierarchically decomposed into
more detailed functions. On the other hand, during structured design, all
functions identified during structured analysis are mapped to a module
structure. This module structure is also called the high-level design or the
software architecture for the given problem. This is represented using a structure
chart.
STRUCTURED ANALYSIS
The structured analysis technique is based on the following underlying principles:
The main reason why the DFD technique is so popular is probably because of the
fact that DFD is a very simple formalism— it is simple to understand and use. A
DFD model uses a very limited number of primitive symbols (shown in Figure) to
represent the functions performed by a system and the data flow among these
functions.
Data flow symbol: A directed arc (or an arrow) is used as a data flow symbol.
A data flow symbol represents the data flow occurring between two processes
or between an external entity and a process in the direction of the data flow
arrow. Data flow symbols are usually annotated with the corresponding data
names. For example the DFD in Figure 6.3(a) shows three data flows—the data
Data store symbol: A data store is represented using two parallel lines. It
represents a logical file. That is, a data store symbol can represent either a data
structure or a physical file on disk. Each data store is connected to a process by
means of a data flow symbol. The direction of the data flow arrow shows
whether data is being read from or written into a data store. An arrow flowing
in or out of a data store implicitly represents the entire data of the data store and
hence arrows connecting to a data store need not be annotated with the name
of the corresponding data items. As an example of a data store, number is a data
store in Figure 6.3(b).
Output symbol: The output symbol is used when a hard copy is produced.
DFD model only represents the data flow aspects and does not show the
sequence of execution of the different functions and the conditions based on
which a function may or may not be executed. It completely ignores aspects such
as control flow, the specific algorithms used by the functions, etc. In the DFD
terminology, each function is called a process or a bubble. It is useful to consider
each function as a processing station (or process) that consumes some input data
and produces some output data.
To develop the data flow model of a system, first the most abstract representation
(highest level) of the problem is to be worked out. Subsequently, the lower
level DFDs are developed. Level 0 and Level 1 consist of only one DFD each.
Level 2 may contain up to 7 separate DFDs, and level 3 up to 49 DFDs, and so
on. However, there is only a single data dictionary for the entire DFD model.
Many beginners commit the mistake of drawing more than one bubble in the
context diagram. Context diagram should depict the system as a single
bubble.
Many beginners create DFD models in which external entities
appearing at all levels of DFDs. All external entities interacting with the
Every data store must have input data flow to store the data and an output data flow
for the retrieved data.
Two data flows can not cross each other.
Context Diagram
The context diagram is the most abstract (highest level) data flow
representation of a system. It represents the entire system as a single bubble. The
bubble in the context diagram is annotated with the name of the software
system being developed.
To develop the context diagram of the system, we have to analyse the SRS
document to identify the different types of users who would be using the
system and the kinds of data they would be inputting to the system and the data
they would be receiving from the system.
Level 1 DFD
The level 1 DFD usually contains three to seven bubbles. That is, the system is
represented as performing three to seven important functions. To develop the
level 1 DFD, examine the high-level functional requirements in the SRS
document. If there are three to seven high-level functional requirements, then
each of these can be directly represented as a bubble in the level 1 DFD. Next,
examine the input data to these functions and the data output by these
To draw the level 1 DFD, from a cursory analysis of the problem description, we
can see that there are four basic functions that the system needs to perform—accept
the input numbers from the user, validate the numbers, calculate the root mean
square of the input numbers and, then display the result.
Level 2 DFD: This level provides an even more detailed view of the system by
breaking down the sub-processes identified in the level 1 DFD into further sub-
processes. Each sub-process is depicted as a separate process on the level 2 DFD.
The data flows and data stores associated with each sub-process are also shown.
Level 2 DFD for University Management System is also the highest abstraction of
the data flow diagram. This level also broadens the idea from the DFD level 1. It
includes the sub- processes from level 1 as well as the data that flows.
Data dictionary
Note: A data dictionary lists the purpose of all data items and the definition of
all composite data items in terms of their component data items.
The dictionary plays a very important role in any software development process,
especially for the following reasons:
versa. Such impact analysis is especially useful when one wants to check the
impact of changing an input value type, or a bug in some functionality, etc.
For large systems, the data dictionary can become extremely complex and
voluminous. Even moderate-sized projects can have thousands of entries in the data
dictionary. It becomes extremely difficult to maintain a voluminous dictionary
manually. Computer-aided software engineering (CASE) tools come handy to
overcome this problem. Most CASE tools usually capture the data items appearing
in a DFD as the DFD is drawn, and automatically generate the data dictionary. As a
result, the designers do not have to spend almost any effort in creating the data
dictionary. These CASE tools also support some query language facility to query
about the definition and usage of data items.
STRUCTURED DESIGN
The basic building blocks using which structure charts are designed are as
following:
• The tasks defined for one purpose cannot refer or change data of other
objects.
• Objects have their internal data which represent their state. Similar objects
create a class.
• In other words, each object is a member of some class. Classes may inherit
features from the super class.
Or
model. The design model is usually obtained by carrying out iterative refinements
to the analysis model using a design methodology.
Objects
For example, consider a manually operated library system. For issuing a book, an
issue register needs to be filled up and then the return date needs to be stamped
Each object essentially consists of some data that is private to the object and a
set of functions (termed as operations or methods ) that operate on those data.
Observe that the data of the object can only be accessed by the methods of the
object.
In other words, no object can directly access the data of any other object.
Therefore, each object can be thought of as hiding its internal data from other
objects. However, an object can access the private data of another object by
invoking the methods supported by that object. This mechanism of hiding data
from other objects is popularly known as the principle of data hiding or data
abstraction.
Class
Similar objects constitute a class. That is, all the objects constituting a class
possess similar attributes and methods. For example, the set of all library
members would constitute the class LibraryMember in a library automation
application. In this case, each library member object has attributes such as
member name, membership number, member address, etc. and also has methods
such as issue-book, return-book, etc.
Abstract data: The data of an object can be accessed only through its methods.
In other words, the exact way data is stored internally (stack, array, queue, etc.) in
the object is abstracted out (not known to the other objects).
Assume that the class provides three definitions for the create operation—int
create(), int create(int radius) and int create(float x, float y, int radius);. In this
case, we say that create is an overloaded method.
Class Relationships
• Inheritance
• Association and link
• Aggregation and composition
• Dependency
Inheritance
A base class is said to be a generalisation of its derived classes. This means that
the base class should contain only those properties (i.e., data and methods) that
are common to all its derived classes. For example, in Figure 7.3 each of the
derived classes supports the issue-book method, and this method is supported by
the base class as well.
Association is a common type of relation among classes. When two classes are
associated, they can take each others help (i.e. invoke each others methods) to
serve user requests. More technically, we can say that if one class is associated
with another bidirectionally, then the corresponding objects of the two classes
know each others ids (identities). As a result, it becomes possible for the object
of one class to invoke the methods of the corresponding object of the other class.
However, there can be situations where three or more different classes can be
involved in an association. As an example of a ternary association, consider
the following—A person books a ticket for a certain show. Here, an association
exists among the classes Person, Ticket, and Show.
A class can have an association relationship with itself. This is called recursive
association or unary association. As an example, consider the following—two
students may be friends. Here, an association named friendship exists among
pairs of objects of the Student class.
Link: When two classes are associated, the relationship between two objects of
the corresponding classes is called a link.
Example 7.1 Consider the following extract from a problem description. Identify
the association relation among classes and the corresponding association links
among objects from an analysis of the description. "A person works for a
company. Ram works for Infosys. Hari works for TCS."
Dependency
A class is said to be dependent on another class, if any changes to the latter class
necessitates a change to be made to the dependent class.
Dependencies among classes may arise due to various causes. Two important
reasons for dependency to exist between two classes are the following:
Abstraction
Encapsulation
The data of an object is encapsulated within its methods. To access the data
internal to an object, other objects have to invoke its methods, and cannot
directly access the data. This concept is schematically shown in Figure 7.8.
Observe from Figure 7.8 that there is no way for an object to access the data
private to another object, other than by invoking its methods.
• Weak coupling: Since objects do not directly change each others internal
data, they are weakly coupled. Weak coupling among objects enhances
understandability of the design since each object can be studied and
understood in isolation from other objects.
Polymorphism
Advantages of OOD
The main reason for the popularity of OOD is that it holds out the following
promises:
Disadvantages of OOD
The following are some of the prominent disadvantages inherent to the object
paradigm:
As the name itself implies, UML is a language for documenting models. As is the
case with any other language, UML has its syntax (a set of basic symbols and
sentence formation rules) and semantics (meanings of basic symbols and
sentences). It provides a set of basic graphical notations (e.g. rectangles, lines,
ellipses, etc.) that can be combined in certain ways to document the design and
analysis results.
Or
Prepared By: Er. Inderjeet Singh(e8822) Page 37
Software Engineering
• The main aim of UML is to define a standard way to visualize the way a
system has been designed.
Note: UML can be used to document object-oriented analysis and design results
that have been obtained using any methodology.
Need of UML
• A lot of time is saved down the line when teams are able to visualize
processes, user interactions and static structure of the system.
UML 2.0
UML 2.0 defines thirteen types of diagrams, divided into three categories as
follows:
Structure diagrams: These include the class diagram, object diagram, component
diagram, composite structure diagram, package diagram, and deployment
diagram.
Behaviour diagrams: These diagrams include the use case diagram, activity
diagram, and state machine diagram.
The use case model for any system consists of a set of use cases.
Example: The use case model for the Tic-tac-toe game software is shown in Figure
7.15. This software has only one use case, namely, “play move”. Note that we did
not name the use case “get-user-move”, as “get-user move” would be
inappropriate because this would represent the developer’s perspective of the
use case. The use cases should be named from the users’ perspective.
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
Prepared By: Er. Inderjeet Singh(e8822) Page 40
Software Engineering
Actors
Actors are external entities that interact with the system. These can include users,
other systems, or hardware devices. In the context of a Use Case Diagram, actors
initiate use cases and receive the outcomes. Proper identification and
understanding of actors are crucial for accurately modeling system behavior.
Use Cases
Use cases are like scenes in the play. They represent specific things your system
can do. In the online shopping system, examples of use cases could be “Place
Order,” “Track Delivery,” or “Update Product Information”. Use cases are
represented by ovals.
System Boundary
The system boundary is a visual representation of the scope or limits of the system
you are modeling. It defines what is inside the system and what is outside. The
boundary helps to establish a clear distinction between the elements that are part
of the system and those that are external to it. The system boundary is typically
represented by a rectangular box that surrounds all the use cases of the system.
Example 7.3 The use case diagram of the Super market prize scheme
Text description
U1: register-customer: Using this use case, the customer can register himself by
providing the necessary details.
4: System: display the generated id and the message that the customer has
successfully been registered.
4: System: displays the message that the customer has already registered.
4: System: displays message that some input information have not been entered.
The system displays a prompt to enter the missing values.
U2: register-sales: Using this use case, the clerk can register the details of the
purchase made by a customer.
2. System: displays prompt to enter the purchase details and the id of the
customer.
U3: select-winners. Using this use case, the manager can generate the winner
list.
2. System: displays the gold coin and the surprise gift winner list.
Include relationship: The includes relationship implies one use case includes the
behaviour of another use case in its sequence of events and actions. The includes
relationship is appropriate when you have a chunk of behaviour that is similar
across a number of use cases.
Example: The use cases issue-book and renew-book both include check-
reservation use case.
Generalisation
Use case generalisation can be used when you have one use case that is similar to
another, but does something slightly differently or something more.
Generalisation works the same way with use cases as it does with classes. The
child use case inherits the behaviour and meaning of the present use case.
Extends
The main idea behind the extends relationship among use cases is that it allows
you show optional system behaviour. An optional system behaviour is executed
only if certain conditions hold, otherwise the optional behaviour is not executed.
This relationship among use cases is also predefined as a stereotype as shown.
Association
Aggregation
Observe that the number 1 is annotated at the diamond end, and a * is annotated
at the other end. This means that one document can have many paragraphs.
Composition
A typical example of composition is an order object where after placing the order,
no item in the order cannot be changed. If any changes to any of the order items
are required after the order has been placed, then the entire order has to be
cancelled and a new order has to be placed with the changed items. In this case,
as soon as an order object is created, all the order items in it are created and as
soon as the order object is destroyed, all order items in it are also destroyed.
CLASS DIAGRAMS
A class diagram describes the static structure of a system. It shows how a system is
structured rather than how it behaves. The static structure of a system comprises
a number of class diagrams and their dependencies. The main constituents of a
class diagram are classes and their relationships—generalisation, aggregation,
association, and various kinds of dependencies.
Example:
Or
The composite structure diagram lets you define how a class is defined by a
further structure of classes and the communication paths between these parts.
Some new core constructs such as parts, ports and connectors are introduced.
Part: The concept of parts makes possible the description of the internal structure
of a class.
Aggregated classes are parts of a class but parts are not necessarily classes, a
part is any element that is used to make up the containing class.
Example: The example in the figure shows how the composite structure diagram
identifies the containing classifier, Car. The diagram frame shows four internal
composite parts of the containing classifier, which represent the four wheels of
the car and are of the type Wheel. A communication link connects the front
wheels and the rear wheels with connectors named frontaxle and rearaxle.
Whenever you create a composite structure diagram from the Car classifier, four
instances of the Wheel class are created. These parts are held by composition
within the Car instance and the front wheels and the rear wheels are linked by
connectors.
Object diagrams
Object diagrams shows the snapshot of the objects in a system at a point in time.
Since it shows instances of classes, rather than the classes themselves, it is often
called as an instance diagram.
Package diagram
We are going to design package diagram for "Track Order" scenario for an online
shopping store. Track Order module is responsible for providing tracking
information for the products ordered by customers. Customer types in the tracking
serial number, Track Order modules refers the system and updates the current
shipping status to the customer.
There is a track order module, it has to talk with other module to know about
the order details, let us call it "Order Details".
Next after fetching Order Details it has to know about shipping details, let us
call that as "Shipping".
Track order should get order details from "Order Details" and "Order Details"
has to know the tracking info given by the customer. Two modules are
accessing each other which suffices <<access>> dual dependency
Deployment Diagram
Component Diagram
Or
Prepared By: Er. Inderjeet Singh(e8822) Page 56
Software Engineering
• 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.
• The data then passes to and through several other components via various
connections before it is output at the ports on the left. Those interfaces on the
left 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 (in which case there would not be
a component symbol in the top right corner) or a subsystem or component of
the overall system (in this case the 'box' is a component itself).
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).
INTERACTION DIAGRAMS
system. Interaction diagrams, as their name itself implies, are models that describe
how groups of objects interact among themselves through message passing to
realise some behaviour.
Note: Typically, each interaction diagram realises the behaviour of a single use
case.
Sequence Diagram
Or
involved in the operation are listed from left to right according to when they take
part in the message sequence.
Example:
Below is a sequence diagram for making a hotel reservation. The object initiating
the sequence of messages is a Reservation window.
Note That: Class and object diagrams are static model views. Interaction diagrams
are dynamic. They describe how objects collaborate.
Notation Description
Actor
• a type of role played by an entity that interacts with the subject (e.g., by
exchanging signals and data)
• represent roles played by human users, external hardware, or other subjects.
Lifeline
Activations
Call Message
Return Message
Self Message
Recursive Message
Communication Diagram
In the example of the notation for a communication diagram, objects (actors in use
cases) are represented by rectangles. In the example (generic communication
diagram):
The objects are Object1, Object2, Object..., ObjectN-1 ..., and ObjectN.
Messages passed between objects are represented by labeled arrows that start
with the sending object (actor) and end with the receiving object.
The sample messages passed between objects are labeled 1: message1, 2:
message2, 3: message3, etc., where the numerical prefix to the message name
indicates its order in the sequence.
Object1 first sends Object2 the message message1, Object2 in turn sends
ObjectN-1 the message message2, and so on.
Messages that objects send to themselves are indicated as loops (e.g., message
message5).
Timing Diagram:
Timing diagrams focus on conditions changing within and among lifelines along a
linear time axis. Timing Diagrams describe behavior of both individual classifiers
and interactions of classifiers, focusing attention on time of occurrence of events
causing changes in the modeled conditions of the Lifelines.
Multiple Compartments
Activity Diagram
Activity diagrams are similar to the procedural flow charts. The main
difference is that activity diagrams support description of parallel activities and
synchronisation aspects involved in different activities.
For example, in Figure 7.32 the swim lane corresponding to the academic section,
the activities that are carried out by the academic section and the specific situation
in which these are carried out are shown.
A state chart diagram is normally used to model how the state of an object
changes in its life time. State chart diagrams are good at describing how the
State chart diagrams are based on the finite state machine (FSM) formalism.
An FSM consists of a finite number of states corresponding to those of the object
being modelled. The object undergoes state changes when specific events
occur.