Unit Iii
Unit Iii
The design document created during the software design in software engineering should be
implementable using a programming language during subsequent coding phase. Software
designer has to keep this in mind while creating the design document.
We will talk about coding phase in later part of this tutorial. Lets move ahead and
cover software design in software engineering for now.
The high level diagram of design process in software engineering is shown below:
A software design which is not correct will never help you to develop good software product.
Suppose if the software designer wrongly captures the relationship between different modules
or wrongly interprets the data flow between two modules then in the next phase software
coders will develop the software product based on the design. And the end software product
is going to have anomaly in it as it would never behave as captured in SRS document during
software requirement and specification phase. This would result in re-work and thus add
unnecessary cost to the software development.
Thus a software designer should be very cautious while designing the layout for the project
and make sure to ensure correctness.
The software design process can be divided into the following three levels or phases of
design:
➢ Interface Design
➢ Architectural Design
➢ Detailed Design
Interface design is the specification of the interaction between a system and its
environment. This phase proceeds at a high level of abstraction with respect to the inner
workings of the system i.e, during interface design, the internal of the systems are
completely ignored, and the system is treated as a black box. Attention is focused on the
dialogue between the target system and the users, devices, and other systems with which it
interacts. The design problem statement produced during the problem analysis step should
identify the people, other systems, and devices which are collectively called agents.
Interface design should include the following details:
1. Precise description of events in the environment, or messages from agents to
which the system must respond.
2. Precise description of the events or messages that the system must produce.
3. Specification of the data, and the formats of the data coming into and going out
of the system.
4. Specification of the ordering and timing relationships between incoming events
or messages, and outgoing events or outputs.
Architectural Design
Architectural design is the specification of the major components of a system, their
responsibilities, properties, interfaces, and the relationships and interactions
between them. In architectural design, the overall structure of the system is chosen,
but the internal details of major components are ignored. Issues in architectural
design includes:
1. Gross decomposition of the systems into major components.
2. Allocation of functional responsibilities to components.
3. Component Interfaces.
4. Component scaling and performance properties, resource consumption
properties, reliability properties, and so forth.
5. Communication and interaction between components.
The architectural design adds important details ignored during the interface design. Design
of the internals of the major components is ignored until the last phase of the design.
Detailed Design
Design is the specification of the internal elements of all major system components, their
properties, relationships, processing, and often their algorithms and the data structures. The
detailed design may include:
1. Decomposition of major system components into program units.
2. Allocation of functional responsibilities to units.
3. User interfaces.
4. Unit states and state changes.
5. Data and control interaction between units.
6. Data packaging and implementation, including issues of scope and visibility of
program elements.
7. Algorithms and data structures.
Design process
Elements of a System
1. Architecture: This is the conceptual model that defines the structure, behavior,
and views of a system. We can use flowcharts to represent and illustrate the
architecture.
2. Modules: These are components that handle one specific task in a system. A
combination of the modules makes up the system.
3. Components: This provides a particular function or group of related functions.
They are made up of modules.
4. Interfaces: This is the shared boundary across which the components of a system
exchange information and relate.
5. Data: This is the management of the information and data flow.
OUTCOME OF DESIGN PHASE
Listed below are the outcome of design phase:
• Various modules required: Software that is going to be developed can be broken down
into different modules. Software design should be able to identify these modules
clearly. Each module will take care of certain important functionality out of all the
activities that the end software product exhibits. For example, if we consider a simple
calculator software then it can be identified to have modules such as addition,
subtraction, division, etc. Each of these can be written as a function with name as
perform Addition, perform Subtraction, etc. Naming your module properly gives clear
indication about the purpose of the module.
• Relationships among modules: The relationship between data flow and function call
between two or different module should be well established during design phase. This
becomes important because one module will call other module with some parameter
and requirement. For example, in calculator software, the main module will call
different modules like perform Addition, perform Division, etc. Now it is necessary to
identify the nature of call like what data will be required during call, what will be
returned as result, etc.
• Interfaces among modules: Interface between modules helps to identify the proper
and exact data which is going to be exchanged between them when one module
invokes other modules functionality.
• Data structure of each modules: Each module of the software design will play around
with data. These data needs to be properly managed with them help of suitable data
structure for smooth functioning of the software product. Thus identifying and
choosing suitable data structure become mandate which needs to be documented as
well in design document.
• Algorithm for each module: Each module will perform some task. These task requires
proper algorithm for their implementation so that space and time complexities issue
doesn't impact the final result and the end software product.
Concepts are defined as a principal idea or invention that comes into our mind or in thought
to understand something. 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. There are many concepts of software design and some of
them are given below:
1. Abstractions
2. Architecture
3. Patterns
4. Modularity
5. Information Hiding
6. Functional Independence
7. Refinement
8. Re-factoring
9. Design Classes
ABSTRACTION:
Many levels of abstraction.
Highest level of abstraction: Solution is slated in broad terms using the language of the
problem environment
Lower levels of abstraction: More detailed description of the solution is provided
• Procedural abstraction-- Refers to a sequence of instructions that a specific and limited
function
• Data abstraction-- Named collection of data that describe a data object
DESIGN CONCEPTS ARCHITECTURE--Structure organization of program components
(modules) and their interconnection Architecture Models
(a) Structural Models-- An organized collection of program components
(b) Framework Models-- Represents the design in more abstract way
(c) Dynamic Models-- Represents the behavioural aspects indicating changes as a function of
external events
(d). Process Models-- Focus on the design of the business or technical process.
Basically, design is a two-part iterative process. The first part is Conceptual Design which
tells the customer what the system will do. Second is Technical Design which allows the
system builders to understand the actual hardware and software needed to solve a customer’s
problem.
Conceptual design of the system:
• Written in simple language i.e. customer understandable language.
• Detailed explanation about system characteristics.
• Describes the functionality of the system.
• It is independent of implementation.
• Linked with requirement document.
Technical Design of the System:
• Hardware component and design.
• Functionality and hierarchy of software components.
• Software architecture
• Network architecture
• Data structure and flow of data.
• I/O component of the system.
• Shows interface.
Modularization: Modularization is the process of dividing a software system into multiple
independent modules where each module works independently. There are many advantages
of Modularization in software engineering. Some of these are given below:
• Easy to understand the system.
• System maintenance is easy.
• A module can be used many times as their requirements. No need to write it again
and again.
Coupling: Coupling is the measure of the degree of interdependence between the modules. A
good software will have low coupling.
Types of Coupling:
• Data 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.
Example-customer billing system.
• Stamp Coupling In stamp coupling, the complete data structure is passed from one
module to another module. Therefore, it involves tramp data. It may be necessary
due to efficiency factors- this choice was made by the insightful designer, not a
lazy programmer.
• Control Coupling: If the modules communicate by passing control information,
then they are said to be control coupled. It can be bad if parameters indicate
completely different behavior and good if parameters allow factoring and reuse of
functionality. Example- sort function that takes comparison function as an
argument.
• External Coupling: In external coupling, the modules depend on other modules,
external to the software being developed or to a particular type of hardware. Ex-
protocol, external file, device format, etc.
• Common Coupling: The modules have shared data such as global data structures.
The changes in global data mean tracing back to all modules which access that
data to evaluate the effect of the change. So it has got disadvantages like difficulty
in reusing modules, reduced ability to control data accesses, and reduced
maintainability.
• Content Coupling: In a content coupling, one module can modify the data of
another module, or control flow is passed from one module to the other module.
This is the worst form of coupling and should be avoided.
• 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.
• 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.
• Communicational Coupling: Communicational coupling occurs when two or more
modules share a common communication mechanism, such as a shared message
queue or database. This type of coupling can lead to performance issues and
difficulty in debugging.
• Functional Coupling: Functional coupling occurs when two modules depend on
each other’s functionality, such as one module calling a function from another
module. This type of coupling can result in tightly-coupled code that is difficult to
modify and maintain.
• Data-Structured Coupling: Data-structured coupling occurs when two or more
modules share a common data structure, such as a database table or data file. This
type of coupling can lead to difficulty in maintaining the integrity of the data
structure and can result in performance issues.
• Interaction Coupling: Interaction coupling occurs due to the methods of a class
invoking methods of other classes. Like with functions, the worst form of
coupling here is if methods directly access internal parts of other methods.
Coupling is lowest if methods communicate directly through parameters.
• Component Coupling: Component coupling refers to the interaction between two
classes where a class has variables of the other class. Three clear situations exist
as to how this can happen. A class C can be component coupled with another class
C1, if C has an instance variable of type C1, or C has a method whose parameter
is of type C1,or if C has a method which has a local variable of type C1. It should
be clear that whenever there is component coupling, there is likely to be
interaction coupling.
Cohesion: Cohesion is a measure of the degree to which the elements of the module are
functionally related. It is the degree to which all elements directed towards performing a
single task are contained in the component. Basically, cohesion is the internal glue that keeps
the module together. A good software design will have high cohesion.
Types of Cohesion:
• Functional Cohesion: Every essential element for a single computation is
contained in the component. A functional cohesion performs the task and
functions. It is an ideal situation.
• Sequential Cohesion: An element outputs some data that becomes the input for
other element, i.e., data flow between the parts. It occurs naturally in functional
programming languages.
• Communicational Cohesion: Two elements operate on the same input data or
contribute towards the same output data. Example- update record in the database
and send it to the printer.
• Procedural Cohesion: Elements of procedural cohesion ensure the order of
execution. Actions are still weakly connected and unlikely to be reusable. Ex-
calculate student GPA, print student record, calculate cumulative GPA, print
cumulative GPA.
• Temporal Cohesion: The elements are related by their timing involved. A module
connected with temporal cohesion all the tasks must be executed in the same time
span. This cohesion contains the code for initializing all the parts of the system.
Lots of different activities occur, all at unit time.
• Logical Cohesion: The elements are logically related and not functionally. Ex- A
component reads inputs from tape, disk, and network. All the code for these
functions is in the same component. Operations are related, but the functions are
significantly different.
• Coincidental Cohesion: The elements are not related(unrelated). The elements
have no conceptual relationship other than location in source code. It is accidental
and the worst form of cohesion. Ex- print next line and reverse the characters of a
string in a single component.
• Procedural Cohesion: This type of cohesion occurs when elements or tasks are
grouped together in a module based on their sequence of execution, such as a
module that performs a set of related procedures in a specific order. Procedural
cohesion can be found in structured programming languages.
• Communicational Cohesion: Communicational cohesion occurs when elements or
tasks are grouped together in a module based on their interactions with each other,
such as a module that handles all interactions with a specific external system or
module. This type of cohesion can be found in object-oriented programming
languages.
• Temporal Cohesion: Temporal cohesion occurs when elements or tasks are
grouped together in a module based on their timing or frequency of execution,
such as a module that handles all periodic or scheduled tasks in a system.
Temporal cohesion is commonly used in real-time and embedded systems.
• Informational Cohesion: Informational cohesion occurs when elements or tasks
are grouped together in a module based on their relationship to a specific data
structure or object, such as a module that operates on a specific data type or
object. Informational cohesion is commonly used in object-oriented programming.
• Functional Cohesion: This type of cohesion occurs when all elements or tasks in a
module contribute to a single well-defined function or purpose, and there is little
or no coupling between the elements. Functional cohesion is considered the most
desirable type of cohesion as it leads to more maintainable and reusable code.
• Layer Cohesion: Layer cohesion occurs when elements or tasks in a module are
grouped together based on their level of abstraction or responsibility, such as a
module that handles only low-level hardware interactions or a module that handles
only high-level business logic. Layer cohesion is commonly used in large-scale
software systems to organize code into manageable layers.
Advantages of low coupling:
• Improved maintainability: Low coupling reduces the impact of changes in one
module on other modules, making it easier to modify or replace individual
components without affecting the entire system.
• Enhanced modularity: Low coupling allows modules to be developed and tested in
isolation, improving the modularity and reusability of code.
• Better scalability: Low coupling facilitates the addition of new modules and the
removal of existing ones, making it easier to scale the system as needed.
Advantages of high cohesion:
• Improved readability and understandability: High cohesion results in clear,
focused modules with a single, well-defined purpose, making it easier for
developers to understand the code and make changes.
• Better error isolation: High cohesion reduces the likelihood that a change in one
part of a module will affect other parts, making it easier to
• Improved reliability: High cohesion leads to modules that are less prone to errors
and that function more consistently,
• leading to an overall improvement in the reliability of the system.
Disadvantages of high coupling:
• Increased complexity: High coupling increases the interdependence between
modules, making the system more complex and difficult to understand.
• Reduced flexibility: High coupling makes it more difficult to modify or replace
individual components without affecting the entire system.
• Decreased modularity: High coupling makes it more difficult to develop and test
modules in isolation, reducing the modularity and reusability of code.
Disadvantages of low cohesion:
• 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.
So our modules are addition Module, subtraction Module, division Module, multiplication
Module. Each one of you pick up one module for development purpose.
Before you enter into development phase, you and your team needs to make sure to design
the project in such a way that each of the module that you develop individually should be
able to perform its assigned task without requiring much or no interaction with your friends
module. What I intend to say is, if you are working on addition Module then your module
should be able to independently perform addition operation on receiving user input. It should
not require to make any interaction with other modules like subtraction Module,
multiplication Module or etc.
This is actually the concept of having module as functional independence of other modules.
There is advantages of functional independence in software engineering which we are going
to discuss next.
Module reusability
A functionally independent module performs some well defined and specific task. So it
becomes easy to reuse such modules in different program requiring same functionality.
Understandability
A functionally independent module is less complex so easy to understand. Since such
modules are less interaction with other modules so can be understood in isolation.
Design patterns
Model-View-Controller (MVC):
Technical Explanation: The Model contains the application's data and business logic. The
View is responsible for rendering the user interface based on the Model's data. The Controller
handles user input, updates the Model, and triggers the necessary changes in the View.
Example: In a Java application, the Model could be a set of JavaBeans, the View could be
implemented using Swing components, and the Controller could use event listeners to capture
user interactions.
Publish-Subscribe (Observer) Pattern:
Technical Explanation: The Observer pattern involves a subject (publisher) and multiple
observers (subscribers). The subject maintains a list of observers and notifies them of any
state changes. Observers implement an interface with an update method to respond to
notifications.
Example: In Java, the java.util.Observable class and java.util.Observer interface can be used.
Subjects extend Observable, and observers implement the update method.
Adapter Pattern:
Technical Explanation: The Adapter pattern allows the integration of incompatible interfaces.
An adapter class wraps an existing class and provides a compatible interface, translating calls
between the new and old systems.
Example: In Java, adapting an existing class to a new interface can be achieved by creating
an adapter class that implements the new interface and delegates calls to the methods of the
existing class.
Command Pattern:
Strategy Pattern:
Technical Explanation: The Strategy pattern defines a family of algorithms, encapsulates each
algorithm, and makes them interchangeable. Clients can switch between strategies at runtime.
Example: In Java, strategies can be implemented as a set of classes or interfaces, each
representing a different algorithm. The context class maintains a reference to the current
strategy and delegates the algorithm's execution to it.
Observer Pattern:
Technical Explanation: The Observer pattern involves a subject and multiple observers.
Observers register with the subject, and when the subject's state changes, it notifies all
registered observers.
Example: In Java, the observer pattern can be implemented using interfaces like Observer and
Observable or by creating custom implementations. Observers register with subjects, and the
subjects notify observers of changes.
Proxy Pattern:
Technical Explanation: The Proxy pattern provides a surrogate or placeholder for another
object to control access. This can involve controlling access, lazy loading, or adding
additional functionality.
Example: In Java, a proxy class can be created that implements the same interface as the real
object. The proxy intercepts method calls, performs additional actions (e.g., lazy loading),
and delegates the actual work to the real object.
Facade Pattern:
ARCHITECTURAL STYLES
Describes a system category that encompasses:
(1) a set of components
(2) a set of connectors that enables “communication and coordination
(3) Constraints that define how components can be integrated to form the system
(4) Semantic models to understand the overall properties of a system Data-flow architectures
Shows the flow of input data, its computational components and output data. Structure is also
called pipe and Filter. Pipe provides path for flow of data. Filters manipulate data and work
independent of its neighbouring filter. If data flow degenerates into a single line of transform,
it is termed as batch sequential. Call and return architectures Achieves a structure that is easy
to modify and scale .Two sub styles (1) Main program/sub program architecture -- Classic
program structure.
Data-flow architectures Shows the flow of input data, its computational components and
output data. Structure is also called pipe and Filter. Pipe provides path for flow of data. Filters
manipulate data and work independent of its neighbouring filter. If data flow degenerates into
a single line of transform, it is termed as batch sequential. Call and return architectures
Achieves a structure that is easy to modify and scale .Two sub styles
(1) Main program/sub program architecture
---Classic program structure
----Main program invokes a number of components, which in turn invoke still
other components
Layered architectures
A number of different layers are defined Inner Layer( interface with OS) •
Intermediate Layer Utility services and application function) Outer Layer
(User interface)
ARCHITECTURAL PATTERNS :
A template that specifies approach for some behavioural characteristics of the
system Patterns are imposed on the architectural styles Pattern Domains
1.Concurrency --Handles multiple tasks that simulate parallelism. --
Approaches (Patterns)
Client-Server Architecture:
Definition: This architecture involves dividing the system into two major
components - the client, which makes requests, and the server, which
processes those requests and provides responses.
Key Characteristics: Separation of concerns, scalability, and easier
maintenance.
Tiered Architecture: