Software Design
Software Design
Software Design
Introduction
• Design phase transforms SRS document
d1 d2
d3 d1 d4
• Two ways
– Modular Design
– Layered Design
Modularity
• A fundamental attribute of any good design
– Functional Independence
– Information hiding
Functional Independence
• When a software program is modularized, its tasks are divided into
several modules based on some characteristics
• Modules are set of instructions put together in order to perform
some tasks
• The quality of the design of modules and their interaction can be
measured by
– Cohesion
– Coupling
• Technically, modules should display
– High cohesion
– Low coupling
Cohesion
• Cohesion is a measure that defines the degree of intra-
dependability among the elements of a module
• The greater the cohesion, the better is the design
• Classification of cohesion
functional
sequential
communicational Degree of cohesion
procedural
temporal
logical
coincidental
Coincidental Cohesion
• Result of breaking the program into smaller modules for the sake
of modularization
– It is unplanned
• It may serve confusion to the programmers
Logical Cohesion
• When logically categorized elements are put together into a module
• All elements of the module perform similar operations
• Example:
– The set of functions responsible for
• initialization
– Example:
sort
search
display
Functional Cohesion
– Elements of module in functional cohesion are grouped because they
all contribute to a single well-defined function
• e.g. managing an employee's pay-roll
– It is considered to be the highest degree of cohesion, and it is highly
expected
– It can also be reused
Coupling
• Coupling is a measure that defines
– The level of inter-dependability among modules of a program
• It tells at what level the modules interfere and interact with each
other
• The lower the coupling, the better the program
Fan in=2
Layered Design
• A design having modules
• Lacks cohesion
• Essentially means
– Low fan-out
– Control abstraction
Control Relationships
• A module that controls another module
– Said to be superordinate to it
– Said to be subordinate to it
Visibility and Layering
• A module A is said to be visible to another module B
• Lower-level modules
• Upper-level modules
• f1
• f2 d2
• f3 d1
•
• d3 d1 d4
•
• fn
Different Design Approaches
• Procedural (or Function-oriented)
• Object-oriented
• More recent
– Aspect-oriented
– Component-based (Client-Server)
Different Design Approaches
• These two design approaches are radically different
– Assign-membership-number
– Create-member-record
– Print-bill
– 80 floors and
– 1000 rooms
– The fire alarm system should let fire fighting personnel reset the
alarms
Function-Oriented Approach
• /* Global data (system state) accessible by various functions */
BOOL detector_status[1000];
int detector_locs[1000];
BOOL alarm-status[1000]; /* alarm activated when status set */
int alarm_locs[1000]; /* room number where alarm is located */
int neighbor-alarms[1000][10];/*each detector has at most*/
/* 10 neighboring alarm locations */
The functions which operate on the system state:
interrogate_detectors();
get_detector_location();
determine_neighbor();
ring_alarm();
reset_alarm();
report_fire_location();
Object-Oriented Approach
• class detector