SE - Lecture 6
SE - Lecture 6
SE - Lecture 6
Engineering
Lecture #3
Software Architecture & Design
Software Design
• Software design deals with transforming the customer
requirements, as described in the SRS document, into a form (a set
of documents) that is suitable for implementation in a
programming language.
• A good software design is seldom arrived by using a single step
procedure but rather through several iterations through a series of
steps.
• Design activities can be broadly classified into two important parts:
• Preliminary (or high-level) design and
• Detailed design.
Preliminary and Detailed design activities
• High-level design means identification of different modules and
the control relationships among them and the definition of the
interfaces among these modules.
• The outcome of high-level design is called the program structure
or software architecture.
Preliminary and detailed design activities
• During detailed design, the data structure and the algorithms of
the different modules are designed.
• The outcome of the detailed design stage is usually known as the
module-specification document.
Cohesion
• Most researchers and engineers agree that a good software design
implies clean decomposition of the problem into modules, and the
neat arrangement of these modules in a hierarchy.
• Cohesion is a measure of functional strength of a module.
• The primary characteristics of neat module decomposition are high
cohesion and low coupling.
• A module having high cohesion and low coupling is said to be
functionally independent of other modules.
Classification of cohesion
Classification of cohesion
• Coincidental ( Random) cohesion: A module is said to have
coincidental cohesion, if it performs a set of tasks that relate to each
other very loosely, if at all. It is likely that the functions have been
put in the module out of pure coincidence without any thought or
design. For example, in a transaction processing system (TPS), the
get-input, print-error, and summarize members functions are
grouped into one module. The grouping does not have any relevance
to the structure of the problem
• Logical cohesion: A module is said to be logically cohesive, if all
elements of the module perform similar operations, e.g. error
handling, data input, data output, etc. An example of logical
cohesion is the case where a set of print functions generating
different output reports are arranged into a single module.
Classification of cohesion
• Temporal cohesion: When a module contains functions that are
related by the fact that all the functions must be executed in the same
time span, the module is said to exhibit temporal cohesion. The set of
functions responsible for initialization, start-up, shutdown of some
process, etc. exhibit temporal cohesion.
• Procedural cohesion: A module is said to possess procedural
cohesion, if the set of functions of the module are all part of a
procedure (algorithm) in which certain sequence of steps have to be
carried out for achieving an objective, e.g. the algorithm for decoding a
message.
• Communicational cohesion: A module is said to have
communicational cohesion, if all functions of the module refer to or
update the same data structure. e.g. the set of functions defined on an
array or a stack.
9
Classification of cohesion
• Sequential cohesion: A module is said to possess sequential
cohesion, if the elements of a module form the parts of sequence,
where the output from one element of the sequence is input to the
next. For example, in a TPS, the get-input, validate-input, sort-
input functions are grouped into one module.
• Functional cohesion: Functional cohesion is said to exist, if
different elements of a module cooperate to achieve a single
function. For example, a module containing all the functions
required to manage employees’ pay-roll exhibits functional
cohesion.
Coupling
create-new-member
delete-member
update-member-record
Object-oriented design
• In fact, the functions defined for one object cannot refer or change
data of other objects.
• Objects have their own internal data which define their state.
• Similar objects constitute a class. In other words, each object is a
member of some class. Classes may inherit features from super class.
• Conceptually, objects communicate by message passing.
Object-oriented design approach
Principle
Criteria
Techniques
21
22
Problem Statement
Traditional Approach
Programmers Approach:
Abstraction
Abstraction continue...
Benefits of Abstraction
Gives the designer freedom to ignore certain
details, for the time being, and to determine or
design the "big picture" aspects of his design
27
Decomposition
Decomposition Rules
Decomposition continues....
Subsystems
Subsystems
A subsystem is a functionally cohesive grouping of
classes that is a major part of a larger aggregate system
Subsystems
Subsystem Example
Student Accounts
Management
Layers
Decomposition of the system into smaller, more
manageable units, that are layered hierarchically.
Layers Rule
Layer can request for services from exactly one
layer below it.
Total Layers = N = 3
Request = N-1
Response = N+ 1
Example on next slide
39
Layer Rule
Services Layers
Request
Operations Layers
Response
Tree-Structures
Problem
An automated ticket issuing system used by passengers at a
railway station. The System should also allow reservation
of seats and give some route information. The passenger
should be able to pay for the ticket at the counter also.
Encapsulation
Encapsulation
Encapsulation Example
Information hiding
Information Hiding
Principle
Criteria
Techniques
55
56
Extensibility
Extensibility
Extensibility
Problem Statement
Solution to example
Open
What is Class
Basic implementation unit in OOP.
Abstract Classes
Inheritance
Polymorphism
In the context of object-oriented programming, is the ability
to create a variable, a function, or an object that has more
than one form.
Types of Polymorphism
Runtime Polymorphism
Example
We have to design a banking system in which
there are several clients who are availing the
facility of maintaining the account in the bank. As
an international norm bank is offering multiple
type of accounts to it’s customers like savings,
current etc. Each account is having a facility of
deposit and withdrawal attached with it for it’s
client.
84
Example
Task to do:
Another Example
You are going to design a library application where a particular request for
The issuanceValidator looks to see if the balance of book is above certain values
Given this problem, one of the developer comes up with the following classes. The
libraryrequestHandler can assess a issue request. This class holds the balance of
remaining books and period of hold of books for a particular student account.
87
Code in Java
88
PersonalLoanValidator Class
public class issuanceValidator {
public issueanceValidator() {
}
public boolean isValid(int balance) {
if(balance>5)
return true;
else
return false;
}
}
90
Task To Do