Nothing Special   »   [go: up one dir, main page]

SE Unit-3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Software Design Concept

Software design is a process to transform user requirements into some suitable form, which helps the
programmer in software coding and implementation.

For assessing user requirements, an SRS (Software Requirement Specification) document is created
whereas for coding and implementation, there is a need of more specific and detailed requirements in
software terms. The output of this process can directly be used into implementation in programming
languages.

Software design is the first step in SDLC (Software Design Life Cycle), which moves the concentration
from problem domain to solution domain. It tries to specify how to fulfill the requirements mentioned
in SRS.

Software Design Levels

Software design yields three levels of results:

​ Architectural Design - The architectural design is the highest abstract version of the system. It
identifies the software as a system with many components interacting with each other. At this
level, the designers get the idea of the proposed solution domain.
​ Interface design/High-level Design- The high-level design breaks the ‘single entity-multiple
component’ concept of architectural design into a less-abstracted view of subsystems and
modules and depicts their interaction with each other. High-level design focuses on how the
system along with all of its components can be implemented in forms of modules. It recognizes
the modular structure of each sub-system and their relation and interaction among each other.
​ Detailed Design- Detailed design deals with the implementation part of what is seen as a system
and its sub-systems in the previous two designs. It is more detailed towards modules and their
implementations. It defines the logical structure of each module and their interfaces to
communicate with other modules.

Objectives of Software Design


1. Correctness: A good design should be correct i.e., it should correctly implement all the
functionalities of the system.
2. Efficiency: A good software design should address the resources, time, and cost
optimization issues.
3. Flexibility: A good software design should have the ability to adapt and accommodate
changes easily. It includes designing the software in a way, that allows for modifications,
enhancements, and scalability without requiring significant rework or causing major
disruptions to the existing functionality.
4. Understandability: A good design should be easily understandable, it should be modular,
and all the modules are arranged in layers.
5. Completeness: The design should have all the components like data structures, modules,
external interfaces, etc.
6. Maintainability: A good software design aims to create a system that is easy to understand,
modify, and maintain over time. This involves using modular and well-structured design
principles e.g.,(employing appropriate naming conventions and providing clear
documentation). Maintainability in Software and design also enables developers to fix bugs,
enhance features, and adapt the software to changing requirements without excessive effort
or introducing new issues.

The software design concept simply means the idea or principle behind the design. It describes how
you plan to solve the problem of designing software, and the logic, or thinking behind how you will
design software. It allows the software engineer to create the model of the system software or product
that is to be developed or built. The software design concept provides a supporting and essential
structure or model for developing the right software.

Modularization

Modularization is a technique to divide a software system into multiple discrete and independent
modules, which are expected to be capable of carrying out task(s) independently. These modules may
work as basic constructs for the entire software. Designers tend to design modules such that they can be
executed and/or compiled separately and independently.

Modular design unintentionally follows the rules of ‘divide and conquer’ problem-solving strategy this
is because there are many other benefits attached with the modular design of a software.

The desirable properties of a modular system are:

○ Each module is a well-defined system that can be used with other applications.

○ Each module has single specified objectives.

○ Modules can be separately compiled and saved in the library.

○ Modules should be easier to use than to build.

○ Modules are simpler from outside than inside.

Advantages of Modularity

○ It allows large programs to be written by several or different people

○ It encourages the creation of commonly used routines to be placed in the library and used by
other programs.

○ It simplifies the overlay procedure of loading a large program into main storage.

○ It provides more checkpoints to measure progress.

○ It provides a framework for complete testing, more accessible to test

○ It produced the well designed and more readable program.

Disadvantages of Modularity

○ Execution time maybe, but not certainly, longer

○ Storage size perhaps, but is not certainly, increased

○ Compilation and loading time may be longer

○ Inter-module communication problems may be increased


○ More linkage required, run-time may be longer, more source lines must be written, and more
documentation has to be done

Modular Design

Modular design reduces the design complexity and results in easier and faster implementation by
allowing parallel development of various parts of a system. We discuss a different section of modular
design in detail in this section:

1. Functional Independence: Functional independence is achieved by developing functions that


perform only one kind of task and do not excessively interact with other modules. Independence is
important because it makes implementation more accessible and faster. The independent modules are
easier to maintain, test, and reduce error propagation and can be reused in other programs as well.
Thus, functional independence is a good design feature which ensures software quality.

It is measured using two criteria:

○ Cohesion: It measures the relative function strength of a module.

○ Coupling: It measures the relative interdependence among modules.

2. Information hiding: The fundamentals of Information hiding suggests that modules can be
characterized by the design decisions that protect from the others, i.e., In other words, modules should
specify that data included within a module is inaccessible to other modules that do not need such
information.

Coupling and Cohesion

When a software program is modularized, its tasks are divided into several modules based on some
characteristics. As we know, modules are a set of instructions put together in order to achieve some
tasks. They are, though, considered as a single entity but may refer to each other to work together.
There are measures by which the quality of a design of modules and their interaction among them can
be measured. These measures are called coupling and cohesion.

Module Coupling

In software engineering, the coupling is the degree of interdependence between software modules. Two modules
that are tightly coupled are strongly dependent on each other. However, two modules that are loosely coupled
are not dependent on each other. Uncoupled modules have no interdependence at all within them.

The various types of coupling techniques are shown in fig:


A good design is the one that has low coupling. Coupling is measured by the number of relations between the
modules. That is, the coupling increases as the number of calls between modules increase or the amount of
shared data is large. Thus, it can be said that a design with high coupling will have more errors.

Types of Module Coupling

1. No Direct Coupling: There is no direct coupling between M1 and M2.


In this case, modules are subordinates to different modules. Therefore, no direct coupling.

2. Data Coupling: When data of one module is passed to another module, this is called data coupling.

3. Stamp Coupling: Two modules are stamp coupled if they communicate using composite data items such as
structure, objects, etc. When the module passes non-global data structure or entire structure to another module,
they are said to be stamp coupled. For example, passing structure variable in C or object in C++ language to a
module.

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.

5. External Coupling: External Coupling arises when two modules share an externally imposed data format,
communication protocols, or device interface. This is related to communication to external tools and devices.

6. Common Coupling: Two modules are common coupled if they share information through some global data
items.
7. Content Coupling: Content Coupling exists among two modules if they share code, e.g., a branch from one
module into another module.

Module Cohesion
In computer programming, cohesion defines to the degree to which the elements of a module belong together.
Thus, cohesion measures the strength of relationships between pieces of functionality within a given module.
For example, in highly cohesive systems, functionality is strongly related.

Cohesion is an ordinal type of measurement and is generally described as "high cohesion" or "low cohesion."

Types of Modules Cohesion


1. Functional Cohesion: Functional Cohesion is said to exist if the different elements of a module
cooperate to achieve a single function.

2. Sequential Cohesion: A module is said to possess sequential cohesion if the element of a module forms
the components of the sequence, where the output from one component of the sequence is input to the
next.

3. Communicational Cohesion: A module is said to have communicational cohesion, if all tasks of the
module refer to or update the same data structure, e.g., the set of functions defined on an array or a
stack.

4. Procedural Cohesion: A module is said to be procedural cohesion if the set of purpose of the module
are all parts of a procedure in which a particular sequence of steps has to be carried out for achieving a
goal, e.g., the algorithm for decoding a message.

5. Temporal Cohesion: When a module includes functions that are associated by the fact that all the
methods must be executed in the same time, the module is said to exhibit temporal cohesion.
6. Logical Cohesion: A module is said to be logically cohesive if all the elements of the module perform a
similar operation. For example Error handling, data input and data output, etc.

7. Coincidental Cohesion: A module is said to have coincidental cohesion if it performs a set of tasks that
are associated with each other very loosely, if at all.

Differentiate between Coupling and Cohesion

Coupling Cohesion

Coupling is also called Inter-Module Cohesion is also called Intra-Module


Binding. Binding.

Coupling shows the relationships Cohesion shows the relationship within the
between modules. module.

Coupling shows the relative Cohesion shows the module's relative


independence between the modules. functional strength.

While creating, you should aim for low While creating you should aim for high
coupling, i.e., dependency among cohesion, i.e., a cohesive component/
modules should be less. 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 In cohesion, the module focuses on a single
other modules. thing.

Structure Charts

A structure chart is a diagrammatic representation of a software system’s components, showcasing the


hierarchical relationship between modules.

● It is a static system representation, focusing on the structure rather than the process.
● Structure Chart represents the hierarchical structure of modules. It breaks down the entire
system into the lowest functional modules and describes the functions and sub-functions of each
module of a system in greater detail.
● Structure charts are primarily used in top-down modular design and structured programming,
where the system is broken down into manageable modules.
● They help visualize the system’s complexity, making it easier for developers to understand and
manage.
● They also assist in identifying potential issues or bottlenecks in the system’s design.

Types of structure charts in software engineering

1. High-level structure charts


● High-level structure charts, or top-level or system-level charts, provide a broad system
overview.
● They depict the main modules and their relationships but need to delve into the details of each
module.
● High-level structure charts are typically used in the early stages of software development, during
the system design phase.
● These charts are crucial for understanding the system’s overall architecture and identifying the
main components.
● They also help divide the system into smaller, more manageable modules, facilitating efficient
project management and collaboration.
2. Detailed structure charts
● As the name suggests, detailed structure charts provide a clear view of the system’s modules.
● They delve into each module’s intricacies, showcasing the sub-modules and their interactions.
● Detailed structure charts are used during the development phase, where they guide the coding
process.
● These charts are instrumental in understanding the system’s inner workings and identifying
potential issues or bottlenecks.
● They also facilitate efficient code management, as developers can quickly identify and isolate
specific modules for modification or debugging.
3. Transaction structure charts
● Transaction structure charts are unique structure charts used in transaction processing systems.
● These charts depict the flow of transactions through the system, showcasing the modules
involved in processing each transaction.
● Transaction structure charts are handy in scenarios where transaction processing is critical, such
as banking or e-commerce systems.
● These charts aid in understanding the transaction flow and identifying potential bottlenecks or
points of failure.
● They also facilitate efficient transaction management, as developers can easily track and manage
individual transactions.

Symbols in Structured Chart

1. Module

It represents the process or task of the system. It is of three types:

● Control Module: A control module branches to more than one submodule.


● Sub Module: Sub Module is a module which is the part (Child) of another module.
● Library Module: Library Module are reusable and invokable from any module.
● Condition - It is represented by small diamond at the base of module. It depicts that control
module can select any of sub-routine based on some condition.

● Jump - An arrow is shown pointing inside the module to depict that the control will jump in the
middle of the sub-module.

● Loop - A curved arrow represents loop in the module. All sub-modules covered by loop repeat
execution of module
.

● Data flow - A directed arrow with empty circle at the end represents data flow.

● Control flow - A directed arrow with filled circle at the end represents control flow.

Example
Structure chart for an Email server
Role of structure charts in software engineering

● Structure charts are pivotal in software engineering, aiding in various stages of the software
development lifecycle.
● They are instrumental in system design, where they help visualise the system’s architecture and
divide it into manageable modules.
● Structure charts guide the coding process during the development phase, facilitating efficient
code management.
● Moreover, structure charts are a valuable tool for project management.
● They visually represent the system’s complexity, making it easier for project managers to plan
and allocate resources.
● They also assist in identifying potential issues or bottlenecks, enabling proactive
problem-solving.

Pseudocode

Pseudocode is an informal way of programming description that does not require any strict
programming language syntax or underlying technology considerations. It is used for creating an
outline or a rough draft of a program. Pseudocode summarizes a program’s flow, but excludes
underlying details. System designers write pseudocode to ensure that programmers understand a
software project's requirements and align code accordingly.
A Pseudocode is defined as a step-by-step description of an algorithm. Pseudocode does not use any
programming language in its representation instead it uses the simple English language text as it is
intended for human understanding rather than machine reading.
Pseudocode is the intermediate state between an idea and its implementation(code) in a high-level
language.
transition of the algorithm into the program.

How to write Pseudocode?


Before writing the pseudocode of any algorithm the following points must be kept in mind.
● Organize the sequence of tasks and write the pseudocode accordingly.
● At first, establishes the main goal or the aim.
Example:

Eg. This program will print first N numbers of Fibonacci series.

● Use standard programming structures such as if-else, for, while, and cases the way we use them
in programming. Indent the statements if-else, for, while loops as they are indented in a
program, it helps to comprehend the decision control and execution mechanism. It also improves
readability to a great extent.
Example:
IF “1”
print response
“I AM CASE 1”
IF “2”
print response
“I AM CASE 2”
● Use appropriate naming conventions. The human tendency follows the approach of following
what we see. If a programmer goes through a pseudo code, his approach will be the same as per
that, so the naming must be simple and distinct.
● Reserved commands or keywords must be represented in capital letters.
Example: if you are writing IF…ELSE statements then make sure IF and ELSE be in capital
letters.
● Check whether all the sections of a pseudo code are complete, finite, and clear to understand and
comprehend. Also, explain everything that is going to happen in the actual code.
● Don’t write the pseudocode in a programming language. It is necessary that the pseudocode is
simple and easy to understand even for a layman or client, minimizing the use of technical
terms.

Good vs Bad ways of writing Pseudocode:

Good Vs Bad way of writing Pseudocode

Pseudocode Examples:

1. Binary search Pseudocode:


Binary search is a searching algorithm that works only for sorted search space. It repeatedly divides the
search space into half by using the fact that the search space is sorted and checking if the desired
search result will be found in the left or right half.

Example: Given a sorted array Arr[] and a value X, The task is to find the index at which X is present
in Arr[].
Below is the pseudocode for Binary search.
BinarySearch(ARR, X, LOW, HIGH)
repeat till LOW = HIGH
MID = (LOW + HIGH)/2
if (X == ARR[mid])
return MID

else if (x > ARR[MID])


LOW = MID + 1

else
HIGH = MID – 1

Advantages of Pseudocode

● Improves the readability of any approach. It’s one of the best approaches to start
implementation of an algorithm.
● Acts as a bridge between the program and the algorithm or flowchart. Also works as a rough
documentation, so the program of one developer can be understood easily when a pseudo
code is written out. In industries, the approach of documentation is essential. And that’s
where a pseudo-code proves vital.
● The main goal of a pseudo code is to explain what exactly each line of a program should do,
hence making the code construction phase easier for the programmer.

Difference between Algorithm and Pseudocode

Algorithm Pseudocode
An Algorithm is used to provide a
A Pseudocode is a step-by-step
solution to a particular problem in
description of an algorithm in code-like
form of a well-defined step-based
structure using plain English text.
form.

An algorithm only uses simple Pseudocode also uses reserved


English words keywords like if-else, for, while, etc.

These are fake codes as the word


These are a sequence of steps of a
pseudo means fake, using code like
solution to a problem
structure and plain English text

There are no rules to writing There are certain rules for writing
algorithms pseudocode

Algorithms can be considered Pseudocode cannot be considered an


pseudocode algorithm

It is difficult to understand and


It is easy to understand and interpret
interpret

Difference between Flowchart and Pseudocode


Flowchart Pseudocode

A Pseudocode is a step-by-step
A Flowchart is pictorial representation
description of an algorithm in code
of flow of an algorithm.
like structure using plain English text.

A Flowchart uses standard symbols for


input, output decisions and start stop Pseudocode uses reserved keywords
statements. Only uses different shapes like if-else, for, while, etc.
like box, circle and arrow.

This is a way of visually representing These are fake codes as the word
data, these are nothing but the graphical pseudo means fake, using code like
representation of the algorithm for a structure but plain English text
better understanding of the code instead of programming language

Pseudocode is better suited for the


Flowcharts are good for documentation
purpose of understanding

Flowchart
Flowchart is a graphical representation of an algorithm. Programmers often use it as a
program-planning tool to solve a problem. It makes use of symbols which are connected among them
to indicate the flow of information and processing.
The process of drawing a flowchart for an algorithm is known as “flowcharting”.

Flowchart symbols
Different types of boxes are used to make flowcharts flowchart Symbols. All the different kinds of
boxes are connected by arrow lines. Arrow lines are used to display the flow of control. Let’s learn
about each box in detail.

Symbol Name Symbol Representation

Terminal/Terminat
or
Process

Decision
Document

Data or
Input/Output
Stored Data

Flow Arrow
Comment or
Annotation

Predefined process
On-page
connector/referenc
e

Off-page
connector/referenc
e

Types of Flowcharts
Three types of flowcharts are listed below:

1. Process flowchart: This type of flowchart shows all the activities that are involved in

making a product. It provides a pathway to analyze the product to be built. A process


flowchart is most commonly used in process engineering to illustrate the relation between
the major as well as minor components present in the product. It is used in business product
modeling to help understand employees about the project requirements and gain some insight
into the project.
2. Data flowchart: As the name suggests, the data flowchart is used to analyze the data,

specifically it helps in analyzing the structural details related to the project. Using this
flowchart, one can easily understand the data inflow and outflow from the system. It is most
commonly used to manage data or to analyze information to and fro from the system.
3. Business Process Modeling Diagram: Using this flowchart or diagram, one can analytically

represent the business process and help simplify the concepts needed to understand business
activities and the flow of information. This flowchart illustrates the business process and
models graphically which paves the way for process improvement.

Advantages of Flowchart
● It is the most efficient way of communicating the logic of the system.
● It acts as a guide for a blueprint during the program design.
● It also helps in the debugging process.
● Using flowcharts we can easily analyze the programs.
● flowcharts are good for documentation.

Disadvantages of Flowchart
● Flowcharts are challenging to draw for large and complex programs.
● It does not contain the proper amount of details.
● Flowcharts are very difficult to reproduce.
● Flowcharts are very difficult to modify.

Solved Examples on FlowChart

Question 1. Draw a flowchart to find the greatest number among the 2 numbers.

Solution:
Algorithm:

1. Start
2. Input 2 variables from user
3. Now check the condition If a > b, goto step 4, else goto step 5.
4. Print a is greater, goto step 6
5. Print b is greater
6. Stop
FlowChart:

Question 2. Draw a flowchart to check whether the input number is odd or even.

You might also like