Software Engineer Notes Unit 3
Software Engineer Notes Unit 3
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.
Problem Partitioning
For small problem, we can handle the entire problem at once but for the significant
problem, divide the problems and conquer the problem it means to divide the
problem into smaller pieces so that each piece can be captured separately.
For software design, the goal is to divide the problem into manageable pieces.
Benefits of Problem Partitioning
These pieces cannot be entirely independent of each other as they together form the
system. They have to cooperate and communicate to solve the problem. This
communication adds complexity.
Note: As the number of partition increases = Cost of partition and complexity increases
Abstraction
An abstraction is a tool that enables a designer to consider a component at an
abstract level without bothering about the internal details of the implementation.
Abstraction can be used for existing element as well as the component being
designed.
1. Functional Abstraction
2. Data Abstraction
Functional Abstraction
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.
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.
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. We
discuss a different section of modular design in detail in this section:
The use of information hiding as design criteria for modular system provides the
most significant benefits when modifications are required during testing's and later
during software maintenance. This is because as most data and procedures are
hidden from other parts of the software, inadvertent errors introduced during
modifications are less likely to propagate to different locations within the software.
Strategy of Design
A good system design strategy is to organize the program modules in such a
method that are easy to develop and latter too, change. Structured design methods
help developers to deal with the size and complexity of programs. Analysts generate
instructions for the developers about how code should be composed and how
pieces of code should fit together to form a program.
1. Top-down Approach
2. Bottom-up Approach
1. Top-down Approach: This approach starts with the identification of the main
components and then decomposing them into their more detailed sub-components.
2. Bottom-up Approach: A bottom-up approach begins with the lower details and
moves towards up the hierarchy, as shown in fig. This approach is suitable in case of
an existing system.
Module Level Concepts :
A module is logically a separable part of the program. it
is a program unit that is discreet and identifiable with respect to compiling and
loading. In terms of common programming language constructs, a module can be
a macro, a function, a procedure, a process or a package. In systems using
functional abstraction, a module is usually a procedure of function or a collection
of these.
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.
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
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.
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
Coupling Cohesion
While creating, you should aim for While creating you should aim for high
low coupling, i.e., dependency cohesion, i.e., a cohesive component/
among modules should be less. module focuses on a single function (i.e.,
single-mindedness) with little interaction
with other modules of the system.
2. Conditional Call
It represents that control module can select any of the sub module on the
basis of some condition.
5. Control Flow
It represents the flow of control between the modules. It is represented
by directed arrow with filled circle at the end.
6. Physical Storage
Physical Storage is that where all the information are to be stored.
Example : Structure chart for an Email server
Modules in a system can be categorized into few classes. There are some
modules that obtain information from their subordinates and then pass it to
their subordinate.There are five types of modules :
1. Input Module
2. Output Module
3. Coordinate Module
4. Transform Module
5. Composite Module
Structured Design Methodology
Introduction: - Creating the software system design is the major
concern of the design phase. Many design techniques have been
proposed over the years to provide some discipline in handling
the complexity of designing large systems. The aim of design
methodologies is not to reduce the process of design to a
sequence of mechanical steps but to provide guidelines to aid the
designer during the design process. Here we describe the
structured design methodology for developing system designs.
Structured design methodology (SDM) views every software
system as having some inputs that are converted into the desired
outputs by the software system. The basic principle behind the
structured design methodology, as with most other
methodologies, is problem partitioning. Structured design
methodology partitions the system at the very top level into
various subsystems, one for managing each major input, one for
managing each major output, and one for each major
transformation. The modules performing the transformation deal
with data at an abstract level, and hence can focus on the
conceptual problem of how to perform the transformation
without bothering with how to obtain clean inputs or how to
present the output.
The rationale behind this partitioning is that in many systems,
particularly data processing systems, a good part of the system
code deals with managing the inputs and outputs. The modules
dealing with inputs have to deal with issues of screens, reading
data, formats, errors, exceptions, completeness of information,
structure of the information, etc. Similarly, the modules dealing
with output have to prepare the output in presentation formats,
make charts, produce reports, etc. Hence, for many systems, it is
indeed the case that a good part of the software has to deal with
inputs and outputs. The actual transformation in the system is
frequently not very complex—it is dealing with data and getting it
in proper form for performing the transformation or producing
the output in the desired form that requires considerable
processing. This partitioning is at the heart of the structured
design methodology. There are four major steps in the
methodology:
1. Restate the problem as a data flow diagram
2. Identify the input and output data elements
3. First-level factoring
4. Factoring of input, output, and transform branches
We will now discuss each of these steps in more detail.
There are two major streams of input data in this diagram. The
first is the account number and the code, and the second is the
amount to be debited. Notice the use of * at different places in the
DFD. For example, the transform “validate,” which verifies if the
account number and code are valid, needs not only the account
number and code, but also information from the system database
to do the validation. And the transform debit account has two
outputs, one used for recording the transaction and the other to
update the account.
First-Level Factoring
Having identified the central transforms and the most abstract
input and output data items, we are ready to identify some
modules for the system. We first specify a main module, whose
purpose is to invoke the subordinates. The main module is
therefore a coordinate module. For each of the most abstract input
data items, an immediate subordinate module to the main module
is specified. Each of these modules is an input module, whose
purpose is to deliver to the main module the most abstract data
item for which it is created.
1)Objects
2)Messages
3)Abstraction
4)Class
5)Attributes
6)Operations
7)Inheritance
8)Polymorphism
9)Encapsulation
10)Hierarchy
Objects: Object is an entity,which has a state and a defined set of operations,which operate on that state.The
state is represented as a set of object attributes. Every object has some properties associated with it, along
with some methods for performing operations on those attributes.
Messages: objects communicate by passing messages.Messages consist of the identity of the target
object,the name of the requested operation and any other operation needed to perform the function.In some
distributed systems,object communications are implemented directly as text messages which object excgange.
Abstraction: Abstraction is used in object-oriented design to deal with complexity. Abstraction is the removal of
the unnecessary and the amplification of the necessary.
Class: Some of the objects may have common characteristics and we can group the objects according to
these characteristics .This type of grouping is known as a ClASS. Hence ,a class is a set of objects that share
a common structure and a common behavior.
“A class represents a template for several object and describe how these objects are structured internally.”
In object oriented system, each objects belongs to a class.an objects,that belongs to a certain class is called an
instance of that class.The class describes the structure ,behavior and information of the instance,while the
current state of the instance is defined by the operations performed on the instance.
Classes are useful because they act as a blue print for objects.
Attributes: An attributes is a data value held by the objects in a class.the square classes has two attributes,a
colour and array of points.Each attributes has a value for each object instance.
Operations:An operations is a function or transformation that may be applied to or by objects in a class.In the
square class,we have two operations:set colour() and draw(). All oblects in a class in a class share the same
operations. Each operation has a target object as an implicit argument. The behavior of the operations depends
on the class of its target.
Inheritance: It allows us to derive a class from another class or a hierarchy of classes that share a set of
attributes and methods.It is a relationship between a superclass and a subclass ,where the subclass inherits
data and behavior from the superclass.
~A class derived from another class is called a subclass or child class.and a class from which the subclass is
derived is called a super class or parent class.
~In the subclass,the inherited attributes or methods can be used directly like any other attributes or methods.
~The subclass can write a new method with the same signature as the one in the superclass a process called
method overriding.
Polymorphism: OOD languages provide a mechanism where methods performing similar tasks but vary in arguments, can
be assigned the same name. This is known as polymorphism, which allows a single interface is performing functions for
different types. Depending upon how the service is invoked, the respective portion of the code gets executed.
Encapsulation: Encapsulation is also called an information hiding concept. The data and operations are linked to a single
unit. Encapsulation not only bundles essential information of an object together but also restricts access to the data and
methods from the outside world.
Hierarchy: It allows code reusability. “IS–A” hierarchy − It defines the hierarchical relationship in inheritance, whereby
from a super-class, a number of subclasses may be derived which may again have subclasses and so on. For example, if
we derive a class Rose from a class Flower, we can say that a rose “is–a” flower.
Coupling: In object oriented design, Coupling refers to the degree of direct knowledge that one element has
of another. In other words, how often do changes in class A force related changes in class B.
There are two types of coupling:
1. Tight coupling : In general, Tight coupling means the two classes often change together.
2.Loose coupling : In simple words, loose coupling means they are mostly independent. If the only knowledge
that class A has about class B, is what class B has exposed through its interface, then class A and class B are
said to be loosely coupled. In order to over come from the problems of tight coupling between objects, spring
framework uses dependency injection mechanism with the help of POJO/POJI model and through dependency
injection its possible to achieve loose coupling.
Cohesion:
Cohesion is used to indicate the degree to which a class has a single, well-focused purpose. Coupling is all about how
classes interact with each other, on the other hand cohesion focuses on how single class is designed. Higher the
cohesiveness of the class, better is the OO design.
Highly cohesive classes are much easier to maintain and less frequently changed.
Such classes are more usable than others as they are designed with a well-focused purpose.
4.Draw the class diagram : The class diagram is responsible for showing the relationship between the classes. There are four
types of relationships available in class diagrams :
d. Association –
It is a semantic connection between classes. At the point when an association associates two classes, each class can send
messages to the next in sequence or a collaboration diagram. They may be bi-directional or unidirectional in nature.
e. Dependencies –
They connect two classes and are always unidirectional in nature and display that one class, depends on the definitions of
another class.
f. Aggregations –
They are a stronger form of association that shows the relationship between a whole and its parts.
g. Generalizations –
They are used to display an inheritance relationship between the two classes.