SOftware design chap 4
SOftware design chap 4
• Software Design
• Design Principles & Concepts
• Effective Modular Design, Cohesion and Coupling, Architectural design
Software Design
• Software design is the first of three technical activities—design, code generation, and test—that are
required to build and verify the software.
• Abstraction
• Refinement
• Modularity
Design Concept (Cont…)
• Abstraction:
• There are three basic types of abstraction.
• A procedural abstraction is a named sequence of instructions that has a specific and limited function. An
example of a procedural abstraction would be the word open for a door. Open implies a long sequence of
procedural steps (e.g., walk to the door, reach out and grasp knob, turn knob and pull door, step away
from moving door, etc.).
• A data abstraction is a named collection of data that describes a data object. In the context of the
procedural abstraction open, we can define a data abstraction called door. Like any data object, the data
abstraction for door would encompass a set of attributes that describe the door (e.g., door type, swing
direction, opening mechanism, weight, dimensions). It follows that the procedural abstraction open would
make use of information contained in the attributes of the data abstraction door.
Design Concept (Cont…)
• Abstraction:
• Control abstraction is the third form of abstraction used in software design. Like procedural and data
abstraction, control abstraction implies a program control mechanism without specifying internal details.
An example of a control abstraction is the synchronization semaphore used to coordinate activities in an
operating system.
• Refinement:
• Stepwise refinement is a top-down design strategy originally proposed by Niklaus Wirth.
• A program is developed by successively refining levels of procedural detail.
• A hierarchy is developed by decomposing a macroscopic statement of function (a procedural abstraction)
in a stepwise fashion until programming language statements are reached.
Design Concept (Cont…)
• Refinement:
• In each step (of the refinement), one or several instructions of the given program are decomposed into
more detailed instructions.
• This successive decomposition or refinement of specifications terminates when all instructions are
expressed in terms of any underlying computer or programming language .
• As tasks are refined, so the data may have to be refined, decomposed, or structured, and it is natural to
refine the program and the data specifications in parallel.
• Abstraction and refinement are complementary concepts. Abstraction enables a designer to specify
procedure and data and yet suppress low-level details. Refinement helps the designer to reveal low-level
details as design progresses. Both concepts aid the designer in creating a complete design model as the
design evolves.
Design Concept (Cont…)
• Modularity:
• Modularity means software is divided into separately named and addressable components, often called
modules, that are integrated to satisfy problem requirements.
• It has been stated that "modularity is the single attribute of software that allows a program to be
intellectually manageable".
• Monolithic software (i.e., a large program composed of a single module) cannot be easily grasped by a
reader. The number of control paths, span of reference, number of variables, and overall complexity
would make understanding close to impossible.
• How to define an appropriate module of a given size?
• Modular decomposability. If a design method provides a systematic mechanism for decomposing the
problem into subproblems, it will reduce the complexity of the overall problem, thereby achieving an
effective modular solution.
Design Concept (Cont…)
• Modularity:
• How to define an appropriate module of a given size?
• Modular composability. If a design method enables existing (reusable) design components to be
assembled into a new system, it will yield a modular solution that does not reinvent the wheel.
• Modular understandability. If a module can be understood as a standalone unit (without reference to
other modules), it will be easier to build and easier to change.
• Modular continuity. If small changes to the system requirements result in changes to individual modules,
rather than system-wide changes, the impact of change-induced side effects will be minimized.
• Modular protection. If an aberrant condition occurs within a module and its effects are constrained within
that module, the impact of error-induced side effects will be minimized.
Effective Modular Design
• Over the years, modularity has become an accepted approach in all engineering disciplines.
• A modular design reduces complexity, facilitates change, and results in easier implementation by
encouraging parallel development of different parts of a system.
• Functional Independence:
• The concept of functional independence is a direct outgrowth of modularity and the concepts of
abstraction and information hiding.
• Functional independence is achieved by developing modules with "single-minded" function and an
"aversion" to excessive interaction with other modules.
• In this, each module addresses a specific sub-function of requirements and has a simple interface when
viewed from other parts of the program structure.
Effective Modular Design (Cont…)
• Functional Independence:
• Software with effective modularity i.e. independent modules, is easier to develop because function may
be compartmentalized and interfaces are simplified.
• Independent modules are easier to maintain (and test) because secondary effects caused by design or
code modification are limited, error propagation is reduced, and reusable modules are possible.
• To summarize, functional independence is a key to good design, and design is the key to software quality.
• Independence is measured using two qualitative criteria: cohesion and coupling.
• Cohesion is a measure of the relative functional strength of a module.
• Coupling is a measure of the relative interdependence among modules.
Effective Modular Design (Cont…)
• Cohesion:
• A cohesive module performs a single task within a software procedure, requiring little interaction with
procedures being performed in other parts of a program.
• A cohesive module should (ideally) do just one thing.
• Cohesion represented as a "spectrum." The scale for cohesion is nonlinear. That is, low-end cohesiveness
is much "worse" than middle range, which is nearly as "good" as high-end cohesion.
• A designer need not be concerned with categorizing cohesion in a specific module. Rather, the overall
concept should be understood and low levels of cohesion should be avoided when modules are designed.
• At the low (undesirable) end of the spectrum, we encounter a module that performs a set of tasks that
relate to each other loosely. Such modules are termed coincidentally cohesive.
Effective Modular Design (Cont…)
• Cohesion:
• A module that performs tasks that are related logically (e.g., a module that produces all output regardless
of type) is logically cohesive.
• When a module contains tasks that are related by the fact that all must be executed with the same span of
time, the module exhibits temporal cohesion.
Effective Modular Design (Cont…)
• Coupling:
• Coupling is a measure of interconnection
among modules in a software structure.
• Coupling depends on the interface
complexity between modules, the point at
which entry or reference is made to a
module, and what data pass across the
interface.
• Architectural Design:
• The software architecture of a program or computing system is the structure or structures of the system,
which comprise software components, the externally visible properties of those components, and the
relationships among them.
• The architecture is not the operational software. Rather, it is a representation that enables a software
engineer to
• (1) analyze the effectiveness of the design in meeting its stated requirements
• (2) consider architectural alternatives at a stage when making design changes is still relatively easy
• (3) reducing the risks associated with the construction of the software.
Effective Modular Design (Cont…)
• Architectural Design:
• Data centered architectures:
• A data store will reside at the center of this architecture and is accessed frequently by the other components
that update, add, delete or modify the data present within the store.
• The figure illustrates a typical data centered style. The client software access a central repository. Variation
of this approach are used to transform the repository into a blackboard when data related to client or data
of interest for the client change the notifications to client software.
• This data-centered architecture will promote integrability. This means that the existing components can be
changed and new client components can be added to the architecture without the permission or concern of
other clients.
• Data can be passed among clients using blackboard mechanism.
Effective Modular Design (Cont…)
• Architectural Design:
• Data flow architectures:
• This kind of architecture is used when input data to be transformed into output data through a series of
computational manipulative components.
• The figure represents pipe-and-filter architecture since it uses both pipe and filter and it has a set of components
called filters connected by pipes.
• Pipes are used to transmit data from one component to the next.
• Each filter will work independently and is designed to take data input of a certain form and produces data output
to the next filter of a specified form. The filters don’t require any knowledge of the working of neighboring filters.
• If the data flow degenerates into a single line of transforms, then it is termed as batch sequential. This structure
accepts the batch of data and then applies a series of sequential components to transform it.
Effective Modular Design (Cont…)
• Architectural Design:
Call and Return architectures: It is used to create a program that is easy to scale and modify. Many sub-styles
exist within this category. Two of them are explained below.
● Remote procedure call architecture: This components is used to present in a main program or sub program
architecture distributed among multiple computers on a network.
● Main program or Subprogram architectures: The main program structure decomposes into number of
subprograms or function into a control hierarchy. Main program contains number of subprograms that can
invoke other components.
Effective Modular Design (Cont…)
• Architectural Design:
● Object Oriented architecture: The components of a system encapsulate data and the operations that must be
applied to manipulate the data. The coordination and communication between the components are established
via the message passing.
● Layered architecture:
a. A number of different layers are defined with each layer performing a well-defined set of operations. Each
layer will do some operations that becomes closer to machine instruction set progressively.
b. At the outer layer, components will receive the user interface operations and at the inner layers,
components will perform the operating system interfacing(communication and coordination with OS)
c. Intermediate layers to utility services and application software functions.
Effective Modular Design (Cont…)
• Architectural Design:
• Layered pattern
• Client-server pattern
• Master-slave pattern
• Pipe-filter pattern
• Broker pattern
• Peer-to-peer pattern
• Event-bus pattern
• Model-view-controller pattern
• Blackboard pattern
• Interpreter pattern
Effective Modular Design (Cont…)
• Architectural Design:
• Layered pattern:
• This pattern can be used to structure programs that can be decomposed into groups of subtasks, each of which is
at a particular level of abstraction. Each layer provides services to the next higher layer.
• Client-server pattern:
• This pattern consists of two parties; a server and multiple clients. The server component will provide services to
multiple client components. Clients request services from the server and the server provides relevant services to
those clients. Furthermore, the server continues to listen to client requests.
• Master-slave pattern:
• This pattern consists of two parties; master and slaves. The master component distributes the work among
identical slave components, and computes a final result from the results which the slaves return.
• Pipe-filter pattern:
• This pattern can be used to structure systems which produce and process a stream of data. Each processing step
is enclosed within a filter component. Data to be processed is passed through pipes. These pipes can be used for
buffering or for synchronization purposes.
Effective Modular Design (Cont…)
• Architectural Design:
• Broker pattern:
• This pattern is used to structure distributed systems with decoupled components. These components can interact
with each other by remote service invocations. A broker component is responsible for the coordination of
communication among components. Servers publish their capabilities (services and characteristics) to a broker.
Clients request a service from the broker, and the broker then redirects the client to a suitable service from its
registry.
• Peer-to-peer pattern:
• In this pattern, individual components are known as peers. Peers may function both as a client, requesting
services from other peers, and as a server, providing services to other peers. A peer may act as a client or as a
server or as both, and it can change its role dynamically with time.
• Event-bus pattern:
• This pattern primarily deals with events and has 4 major components; event source, event listener, channel and
event bus. Sources publish messages to particular channels on an event bus. Listeners subscribe to particular
channels. Listeners are notified of messages that are published to a channel to which they have subscribed
before.
Effective Modular Design (Cont…)
• Architectural Design:
• Model-view-controller pattern:
• This pattern, also known as MVC pattern, divides an interactive application in to 3 parts as,
1. model — contains the core functionality and data
2. view — displays the information to the user (more than one view may be defined)
3. controller — handles the input from the user
• This is done to separate internal representations of information from the ways information is presented to, and
accepted from, the user. It decouples components and allows efficient code reuse.
• Interpreter pattern:
• This pattern is used for designing a component that interprets programs written in a dedicated language. It mainly
specifies how to evaluate lines of programs, known as sentences or expressions written in a particular language. The
basic idea is to have a class for each symbol of the language.
Effective Modular Design (Cont…)
• Architectural Design:
• Blackboard pattern
• This pattern is useful for problems for which no deterministic solution strategies are known. The blackboard
pattern consists of 3 main components.
● blackboard — a structured global memory containing objects from the solution space
● knowledge source — specialized modules with their own representation
● control component — selects, configures and executes modules.
● All the components have access to the blackboard. Components may produce new data objects that are added to the
blackboard. Components look for particular kinds of data on the blackboard, and may find these by pattern matching
with the existing knowledge source.