Professional Documents
Culture Documents
Software Design
Software Design
Software Design
Sukanya Basu
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 1 / 40
Introduction
• Design phase transforms SRS document
- to a form that is easily implementable in some programming language
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 2 / 40
Classification of Design Methodologies
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 3 / 40
Analysis versus Design
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 4 / 40
Good Software Design
A good design
• Should implement all functionalities of the system correctly
• Should be easily understandable
• Should be efficient
• Should be easily amenable to change, i.e. easily maintainable
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 5 / 40
Understandability
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 6 / 40
How to achieve understandability
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 7 / 40
Modularity
• Modularity is a fundamental attributes of any good design
• Decomposition of a problem cleanly into modules
• Modules are almost independent of each other
• Divide and conquer principle
• Module structure
• Control relationship among the modules
• call relationship or invocation relationship
• Interface among different modules
• Data items exchanged among different modules
• Data structures of individual modules
• Algorithms for individual modules
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 9 / 40
• Design activities are usually classified into two stages
• Preliminary (or high-level) design
• Detailed design
• Meaning and scope of the two stages
• Vary considerably from one methodology to another
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 10 / 40
High-Level Design
• Identify
• Modules
• Control relationships among modules
• Interfaces among modules
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 11 / 40
Detailed Design
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 12 / 40
Cohesion and Coupling
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 13 / 40
Advantages of Functional Independence
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 14 / 40
Classification of Cohesiveness
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 15 / 40
Classification of Cohesiveness
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 16 / 40
Classification of Cohesiveness
• Coincidental Cohesion
• The module performs a set of tasks: Which relate to each other very loosely, if
at all
• The module contains a random collection of functions
• Functions have been put in the module out of pure coincidence without any
thought or design
• Logical Cohesion
• All elements of the module perform similar operations
• e.g. error handling, data input, data output, etc
• An example of logical cohesion
- A set of print functions to generate an output report arranged into a single
module
• Temporal Cohesion
• The module contains tasks that are related by the fact:
- All the tasks must be executed in the same time span
• Example:
- The set of functions responsible for initialization, start-up, shut-down of some
process, etc.
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 17 / 40
Classification of Cohesiveness
• Procedural Cohesion
• All part of a procedure (algorithm)
• Certain sequence of steps have to be carried out in a certain order for
achieving an objective
- e.g. the algorithm for decoding a message
• Communicational Cohesion
• All functions of the module: Reference or update the same data structure
• Example:
- The set of functions defined on an array or a stack
• Sequential Cohesion
• Elements of a module form different parts of a sequence
- Output from one element of the sequence is input to the next
• Example:
- Sort → Search → Display
• Functional Cohesion
• Different elements of a module cooperate To achieve a single function
- e.g. managing an employee’s pay-roll
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 18 / 40
Coupling
• Indicates
• How closely two modules interact or how interdependent they are
• The degree of coupling between two modules depends on their interface
complexity
• There are no ways to precisely determine coupling between two modules
• Classification of different types of coupling will help us to approximately
estimate the degree of coupling between two modules
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 19 / 40
Classification of Coupling
• Data coupling
• Two modules are data coupled
• If they communicate via a parameter
- an elementary data item, eg., an integer, a float, a character, etc.
• The data item should be problem related
- Not used for control purpose
• Stamp Coupling
• Two modules are stamp coupled
• If they communicate via a composite data item
- eg., a structure in C
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 20 / 40
Classification of Coupling
• Control Coupling
• Data from one module is used to direct
• Order of instruction execution in another
• Example of control coupling
• A flag set in one module and tested in another module
• Common Coupling
• Two modules are common coupled
• If they share some global data
• Content Coupling
• Content coupling exists between two modules
• If they share code
- eg, branching from one module into another module
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 21 / 40
Layered Design
• Essentially means
• Low fan-out
• Control abstraction
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 22 / 40
Layered Design
• Module structure:
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 23 / 40
Goodness of Design
• A module that invokes a large number of other modules
• Likely to implement several different functions
• Not likely to perform a single cohesive function
Control Relationships
• A module that controls another module
• Said to be superordinate to it
• Conversely, a module controlled by another module
• Said to be subordinate to it
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 24 / 40
Visibility and Layering
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 25 / 40
Abstraction
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 26 / 40
High-level Design
High-level design maps functions into modules {fi} {mj} such that
• Each module has high cohesion
• Coupling among modules is as low as possible
• Modules are organized in a neat hierarchy
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 27 / 40
Design Approaches
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 28 / 40
Function-Oriented Design
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 29 / 40
Example
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 30 / 40
Function-Oriented Design
• Each subfunction
• Split into more detailed subfunctions and so on
• The system state is centralized
• Accessible to different functions
• Member-records available for reference and updation to several functions
• Create-new-member
• Delete-member
• Update-member-record
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 31 / 40
Function-Oriented Design
• Function-Oriented Design
• Structured design (Constantine and Yourdon, 1979)
• Jackson’s structured design (Jackson, 1975)
• Warnier-Orr methodology
• Wirth’s step-wise refinement
• Hatley and Pirbhai’s Methodology
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 32 / 40
Object-Oriented Design
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 33 / 40
Object-Oriented versus Function-Oriented Design
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 34 / 40
Object-Oriented Design Example
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 35 / 40
Object-Oriented versus Function-Oriented Design
• In OOD
• State information is not shared in a centralized data
• But is distributed among the objects of the system
• Objects communicate by message passing
• One object may discover the state information of another object by
interrogating it
• Of course, somewhere or other the functions must be implemented
• The functions are usually associated with specific real-world entities (objects)
• Directly access only part of the system state information
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 36 / 40
Fire-Alarm System
• We need to develop a computerized fire alarm system for a large multi-storied
building
• There are 80 floors and 1000 rooms in the building
• Different rooms of the building
• Fitted with smoke detectors and fire alarms
• The fire alarm system would monitor
• Status of the smoke detectors
• Whenever a fire condition is reported by any smoke detector
• the fire alarm system should
- Determine the location from which the fire condition was reported
- Sound the alarms in the neighboring locations
• The fire alarm system should
• Flash an alarm message on the computer console
• Fire fighting personnel man the console round the clock
• After a fire condition has been successfully handled
• The fire alarm system should let fire fighting personnel reset the alarms
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 37 / 40
Function-Oriented Approach
1 / * G l o b a l d a t a ( s y s t e m s t a t e ) a c c e s s i b l e by v a r i o u s f u n c t i o n s * /
2 BOOL d e t e c t o r s t a t u s [ 1 0 0 0 ] ;
3 int detector locs [1000];
4 BOOL a l a r m−s t a t u s [ 1 0 0 0 ] ; / * a l a r m a c t i v a t e d when s t a t u s s e t * /
5 int a l a r m l o c s [ 1 0 0 0 ] ; / * room number w h e r e a l a r m i s l o c a t e d * /
6 int n e i g h b o r −a l a r m s [ 1 0 0 0 ] [ 1 0 ] ; / * e a c h d e t e c t o r h a s a t most * /
7 / * 10 n e i g h b o r i n g a l a r m l o c a t i o n s * /
8
9 The f u n c t i o n s w h i c h o p e r a t e on t h e s y s t e m s t a t e :
10 interrogate detectors () ;
11 get detector location () ;
12 determine neighbor () ;
13 ring alarm () ;
14 reset alarm () ;
15 r e p o r t f i r e l o c a t i o n () ;
16
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 38 / 40
Object-Oriented Approach
1 class detector
2 a t tr i b ut e s : status , location , neighbors
3 o p e r a t i o n s : c r e a t e , s e n s e −s t a t u s , g e t−l o c a t i o n , f i n d −n e i g h b o r s
4
5 c l a s s alarm
6 attributes : location , status
7 o p e r a t i o n s : c r e a t e , r i n g −a l a r m , g e t l o c a t i o n , r e s e t −a l a r m
8
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 39 / 40
Object-Oriented versus Function-Oriented Design
Sukanya Basu (Techno India University) Software Engineering June 10, 2021 40 / 40