Software Design
Software Design
Software design principles are concerned with providing means to handle the
complexity of the design process effectively.
Effectively managing the complexity will not only reduce the effort needed for design
but can also reduce the scope of introducing errors during design.
For small problem, we can handle the entire problem at once; but for any
big/complex/ significant problem, a principle called divide the problems and
conquer on it if followed where the problem is divided into smaller meaningful and
manageable pieces so that each piece can be captured separately.
NOTE: The entire pieces after partitioning cannot be entirely independent of each other
as they together form the system. They have to cooperate and communicate each other
to solve the problem that results in complexity.
2. Abstraction
1. Functional Abstraction
2. Data Abstraction
Functional Abstraction
i. A module is specified by the method it performs.
ii. The details of the algorithm to accomplish the functions are not visible to the
user of the function.
Functional abstraction forms the basis for Function oriented design approaches.
Data Abstraction
Details of the data elements are not visible to the users of data. Data Abstraction
forms the basis for Object Oriented design approaches.
3. Modularity
Modularity specifies to the division of software into separate modules which are
differently named and addressed and are integrated later on in to obtain the
completely functional software.
It is the only property that allows a program to be intellectually manageable.
Single large programs are difficult to understand and read due to a large
number of reference variables, control paths, global variables, etc.
o Each module is a well-defined system that can be used with other applications.
o Each module has single specified objectives.
o Modules can be separately compiled and saved in the library.
o Modules should be easier to use than to build.
o Modules are simpler from outside than inside.
Advantages of Modularity
Disadvantages of Modularity
Modular design reduces the design complexity and results in easier and faster
implementation by allowing parallel development of various parts of a system.
i. Functional Independence:
The use of information hiding as design criteria for modular system provides
the most significant benefits when modifications are required during testing
and later during software maintenance.
This is because as most data and procedures are hidden from other parts of the
software.
Strategy of Design
1. Top-down Approach
2. Bottom-up Approach
Top-down Approach:
Bottom-up Approach:
A bottom-up approach begins with the lower details and moves towards
up the hierarchy, as shown in fig.
The smaller problems are solved, and then these solved problems are
integrated to find the solution to a bigger problem.
It uses composition approach
It requires relatively more communication between modules.
Data encapsulation and data hiding is implemented in this approach.
Highly preferred in OOPs; programming paradigm such as C++, Java,
Python, etc.
1. No Direct Coupling:
If the dependency between the modules is based on the fact that they
communicate by passing only data, then the modules are said to be data
coupled.
In data coupling, the components are independent of each other and
communicate through data. Module communications don’t contain tramp data.
3. Stamp Coupling:
Two modules are stamp coupled if they communicate using composite data
items such as structure, objects, etc.
4. Control Coupling: Control Coupling exists among two modules if data from one
module is used to direct the structure of instruction execution in another.
Two modules are common coupled if they share information through some
global data items.
The changes in global data mean tracing back to all modules which access that
data to evaluate the effect of the change.
7. Content Coupling:
Content Coupling exists among two modules if they share code, e.g., a branch
from one module into another module.
One module can modify the data of another module, or control flow is passed from
one module to the other module.
8. Temporal Coupling:
Temporal coupling occurs when two modules depend on the timing or order of
events, such as one module needing to execute before another.
This type of coupling can result in design issues and difficulties in testing and
maintenance.
9. Sequential Coupling:
Sequential coupling occurs when the output of one module is used as the
input of another module, creating a chain or sequence of dependencies.
This type of coupling can be difficult to maintain and modify.
Module Cohesion
Coupling Cohesion
Coupling is also called Inter-Module Binding. Cohesion is also called Intra-Module Binding.
Coupling shows the relationships between Cohesion shows the relationship of elements within
modules.(Dependency) the module.(Independence)
While creating, it is preferred aim for low While creating or designing modules, it is preferred
coupling, i.e., dependency among modules to aim for high cohesion, i.e., a cohesive
should be less. component/ module focuses on a single function
(i.e., single-mindedness) with little interaction with
other modules of the system.
In coupling, modules are linked to the other In cohesion, the module focuses on a single thing.
modules.
Increased code duplication: Low cohesion can lead to the duplication of code, as
elements that belong together are split into separate modules.
Reduced functionality: Low cohesion can result in modules that lack a clear
purpose and contain elements that don’t belong together, reducing their
functionality and making them harder to maintain.
Difficulty in understanding the module: Low cohesion can make it harder for
developers to understand the purpose and behavior of a module, leading to
errors and a lack of clarity.