Unit 3 Software Engineering
Unit 3 Software Engineering
Engineering
Unit 3
By
Shivani Agarwal
Software Design
• Software Design is the process to transform the user requirements into some
suitable form, which helps the programmer in software coding and
implementation.
• During the software design phase, the design document is produced, based on
the customer requirements as documented in the SRS document. Hence the
aim of this phase is to transform the SRS document into the design document.
• The following items are designed and documented during the design phase:
• Different modules required.
• Control relationships among modules.
• Interface among different modules.
• Data structure among the different modules.
• Algorithms required to implement among the individual modules.
Software Design Concepts
• 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, the logic, or thinking behind how you will design
software.
• It allows the software engineer to create the model of the system or
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:
Software Design Concepts: Abstraction-
hide details
• Abstraction simply means to hide the details to reduce
complexity and increases efficiency or quality.
• Different levels of Abstraction are necessary and must be
applied at each stage of the design process so that any error
that is present can be removed to increase the efficiency of
the software solution and to refine the software solution.
• The solution should be described in broadways that cover a
wide range of different things at a higher level of abstraction
and a more detailed description of a solution of software
should be given at the lower level of abstraction.
Software Design Concepts: Modularity- subdivide the system
Ex- VALIDATE_PRODUCT_REC
IF TRANS_TYPE NOT = ‘0’ THEN
WRITE _ERR_REPORT
ENDIF
IF CUST_NO NOT NUMERIC THEN
WRITE_ERR_REPORT
ENDIF
IF PRODUCT_NO = BLANKS
WRITE_ERR_REPORT
ENDIF
END
Procedural Cohesion
• A procedurally cohesive module contains elements that belong to a common procedural unit.
• For example, a loop or a sequence of decision statements in a module may be combined to
form a separate module.
• Procedurally cohesive modules often occur when modular structure is determined from
some form of flowchart.
• Procedural cohesion often cuts across functional hues.
• A module with only procedural cohesion may contain only part of a complete function or
parts of several functions.
Ex- READ_STUD_REC _AND_TOTAL_STUDENT _AGES
NO_OF_REC = 0
TOTAL_AGE = 0
READ STUD_REC
DO WHILE MORE_REC_EXIST
ADD AGE TO TOTAL_AGE
ADD 1 TO NO_OF_REC
READ STUD_REC
ENDDO
END
Temporal Cohesion
• Modules that perform activities like "initialization," "clean-up," and
"termination" are usually temporally bound.
• Even though the elements in a temporally bound module are logically related,
temporal cohesion is higher than logical cohesion, because the elements are
all executed together.
• This avoids the problem of passing the flag, and the code is usually simpler.
• – INITIALIZATION
OPEN TRANS_FILE
ISSUE PROMPT ‘ENTER DATE – DDMMYY’
READ TODAYS_DATE
SET TRANS_COUNT TO 0
SET REPORT_TOTAL TO 0
OPEN REPORT_FILE
END
Logical Cohesion
• The instructions are hardly related to each other at all
• The instructions are grouped together due to certain classes or activities.
• A flag that is passed from outside will determine which set of instructions is
to be executed.
Ex – READ_ALL_FILES
CASE OF FILE_CODE
1: READ CUST_TRAN_REC
IF NOT EOF
INCREMENT CUST_TRAN_COUNT
ENDIF
2: READ CUST_MASTER_REC
IF NOT EOF
INCREMENT CUST_MASTER_COUNT
ENDIF
END CASE
END
Coincidental Cohesion
• The instructions have no relationship to each other at all, it is just a coincidence they
fall in the same module.
• It is the worst type of cohesion.
Ex- FILE PROCESSING
OPEN EMPLOYEE_UPDATE FILE
READ EMPLOYEE REC
PRINT_PAGE_HEADING
OPEN MASTER FILE(EMPLOYEE)
SET PAGE_COUNT TO 1
SET ERR_FLAG TO FLASE
END
Difference between Coupling and
COHESION
Cohesion COUPLING
Cohesion is the concept of intra Coupling is the concept of inter
module. module.
Cohesion represents the Coupling represents the
relationship within module. relationships between modules.
Increasing in cohesion is good for Increasing in coupling is avoided
software. for software.
Cohesion represents the functional Coupling represents the
strength of modules. independence among modules.
Highly cohesive gives the best Whereas loosely coupling gives the
software. best software.
In cohesion, module focuses on the In coupling, modules are
single thing. connected to the other modules.
Top-down Design
A top down design approach starts by identifying the major modules of the system,
decomposing them into their lower level modules and iterating until the desired level of
detail is achieved. This is stepwise refinement; starting from an abstract design, in each
step the design is refined to a more concrete level, until we reach a level where no more
refinement is needed and the design can be implemented directly
6. Flow lines: Flow lines indicate the exact sequence in which instructions are
executed. Arrows represent the direction of flow of control and relationship
among different symbols of flowchart.
Flowchart: Benefits
• Logic understanding
• Effective analysis
• Useful in coding
• Proper testing and debugging
• Appropriate documentation
Flowchart: Limitations
1. Complex
2. Costly
3. Difficult to modify
4. No update
Pseudo Code
• Pseudo code is a term which is often used in programming and algorithm-based
fields.
• It is a methodology that allows the programmer to represent the implementation of
an algorithm.
• It is the cooked-up representation of an algorithm.
• Often at times, algorithms are represented with the help of pseudo codes as they
can be interpreted by programmers no matter what their programming background
or knowledge is.
• It’s simply an implementation of an algorithm in the form of annotations and
informative text written in plain English. It has no syntax like any of the
programming language and thus can’t be compiled or interpreted by the computer.
Pseudo Code
• 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.
Pseudo Code
Function Oriented Design
• The design process for software systems often has two levels. At the first
level the focus is on deciding which modules are needed for the system
based on SRS (Software Requirement Specification) and how the modules
should be interconnected.
• Function Oriented Design is an approach to software design where the
design is decomposed into a set of interacting units where each unit has a
clearly defined function.
• Generic Procedure: Start with a high-level description of what the
software / program does. Refine each part of the description one by one by
specifying in greater details the functionality of each part. These points lead
to Top-Down Structure.
Function Oriented Design
Strategies
1.Data Flow Diagram (DFD):A data flow diagram (DFD) maps out the flow of
information for any process or system. It uses defined symbols like
rectangles, circles and arrows, plus short text labels, to show data inputs,
outputs, storage points and the routes between each destination.
2.Data Dictionaries: Data dictionaries are simply repositories to store
information about all data items defined in DFDs. At the requirement stage,
data dictionaries contains data items. Data dictionaries include Name of the
item, Aliases (Other names for items), Description / purpose, Related data
items, Range of values, Data structure definition / form.
3.Structure Charts: It is the hierarchical representation of system which
partitions the system into black boxes (functionality is known to users but
inner details are unknown). Components are read from top to bottom and left
to right. When a module calls another, it views the called module as black
box, passing required parameters and receiving results.
4.Pseudo Code : Pseudo Code is system description in short English like
phrases describing the function. It use keyword and indentation. Pseudo
codes are used as replacement for flow charts. It decreases the amount of
Object Oriented Design
The state is distributed among the objects, and each object handles its
state data. For example, in a Library Automation Software, each library
representative may be a separate object with its data and functions to
operate on these data.
The tasks defined for one purpose cannot refer or change data of other
objects. Objects have their internal data which represent their state.
Similar objects create a class. In other words, each object is a member
of some class. Classes may inherit features from the superclass.
Object Oriented Design
1.Objects: All entities involved in the solution design are known as objects.
For example, person, banks, company, and users are considered as objects.
Every entity has some attributes associated with it and has some methods to
perform on the attributes.
2.Classes: A class is a generalized description of an object. An object is an
instance of a class. A class defines all the attributes, which an object can
have and methods, which represents the functionality of the object.
3.Messages: Objects communicate by message passing. Messages consist of
the integrity of the target object, the name of the requested operation, and
any other action needed to perform the function. Messages are often
implemented as procedure or function calls.
4.Abstraction In object-oriented design, complexity is handled using
abstraction. Abstraction is the removal of the irrelevant and the amplification
of the essentials.
5.Encapsulation: Encapsulation is also called an information hiding concept.
The data and operations are linked to a single unit. Encapsulation not only
Object Oriented Design
6. Inheritance: OOD allows similar classes to stack up in a hierarchical
manner where the lower or sub-classes can import, implement, and re-use
allowed variables and functions from their immediate super classes. This
property of OOD is called an inheritance. This makes it easier to define a
specific class and to create generalized classes from specific ones.
7. 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.
FUNCTIONAL PROGRAMMING OBJECT ORIENTED PROGRAMMING
This programming paradigm emphasizes on This programming paradigm is based on object
the use of functions where each function oriented concept. Classes are used where
performs a specific task. instance of objects are created
Fundamental elements used are variables and Fundamental elements used are objects and
functions. The data in the functions are methods and the data used here are mutable
immutable(cannot be changed after creation). data.
Importance is not given to data but to Importance is given to data rather than
functions. procedures.
It follows declarative programming model. It follows imperative programming model.
The weighting factors are identified for all functional units and multiplied with the
functional units accordingly.
Function Point Metric Computation:
Unadjusted Function Point
• The procedure for the calculation of UFP in mathematical form is given
below:
Wij : It is the entry of the ith row and jth column of the table 1
Zij : It is the count of the number of functional units of Type i that have been
classified as having the complexity corresponding to column j.
Function Point
• Organizations that use function point methods develop a criterion for
determining whether a particular entry is Low, Average or High.
• Nonetheless, the determination of complexity is somewhat subjective.
• FP = UFP * CAF
• Where CAF is complexity adjustment factor and is equal to [0.65 +
0.01 x Fi]. The Fi (i=1 to 14) are the degree of influence and are
based on responses to questions noted
Function Point
• Functions points may compute the following important metrics:
• Productivity = FP / persons-months
• Quality = Defects / FP
• Cost = Rupees / FP
• Documentation = Pages of documentation per FP
• These metrics are controversial and are not universally acceptable. There are
standards issued by the International Functions Point User Group (IFPUG,
covering the Albrecht method) and the United Kingdom Function Point User
Group (UFPGU, covering the MK11 method). An ISO standard for function
point method is also being developed.
Example
• Consider a project with the following functional units:
• Number of user inputs = 50
• Number of user outputs = 40
• Number of user enquiries = 35
• Number of user files = 06
• Number of external interfaces = 04
• Assume all complexity adjustment factors and weighting factors are
average. Compute the function points for the project.
• UFP = 50 x 4 + 40 x 5 + 35 x 4 + 6 x 10 + 4 x 7
• = 200 + 200 + 140 + 60 + 28 = 628
• CAF = (0.65 + 0.01 Fi)
• = (0.65 + 0.01 (14 x 3)) = 0.65 + 0.42 = 1.07
• FP = UFP x CAF
• = 628 x 1.07 = 672
Question
• An application has the following:
• 10 low external inputs, 12 high external outputs, 20 low internal logical
files, 15 high external interface files, 12 average external inquiries, and
a value of complexity adjustment factor of 1.10.
• What are the unadjusted and adjusted function point counts ?
Solution
Halstead’s Software Metrics
• A computer program is an implementation of an algorithm considered to be a
collection of tokens which can be classified as either operators or
operands. Halstead’s metrics are included in a number of current
commercial tools that count software lines of code. By counting the tokens
and determining which are operators and which are operands, the following
base measures can be collected :
n1 : Number of distinct operators.
n2: Number of distinct operands.
N1: Total number of occurrences of operators.
N2: Total number of occurrences of operands.
In addition to the above, Halstead defines the following:
n1*: Number of potential operators.
n2*: Number of potential operands.
• Halstead refers to n1* and n2* as the minimum possible number of operators
Halstead’s Software Metrics
• This minimum number would be embodied in the programming
language itself, in which the required operation would already exist
(for example, in C language, any program must contain at least the
definition of the function main()), possibly as a function or as a
procedure: n1* = 2, since at least 2 operators must appear for any
function or procedure : 1 for the name of the function and 1 to serve
as an assignment or grouping symbol, and n2* represents the number
of parameters, without repetition, which would need to be passed on
to the function or the procedure.
Halstead’s Metrics
• Halstead's metrics are all defined based on its set of base quantities (n1, n2, N1,
N2, n1* and n2*).
• The length (N) of a program P is :
• N = N1 + N2
• The vocabulary (n) of a program P is :
• n = n1 + n2
• The volume (V) of a program P is defined as :
• V = N * log2n
Halstead’s Metrics
• Difficulty level (D) = ( n1 / 2 ) * ( N2 / n2 )
• Program level (L) = 1/D
• Effort to implement (E) = V * D
Halstead’s Software Metrics
Cyclomatic Complexity
= Total number of closed regions in the control flow
graph + 1
=2+1
=3
Method-02:
Cyclomatic Complexity
=E–N+2
=8–7+2
=3
Consider a software project with the following functional units:
User input = 35, User output = 15, User Enquiries = 10, User Files = 6, External Interfaces
= 7.
Assume complexity adjustment factors are essential and weighting factors are average.
Calculate the functional point for the project.
Consider a software project with the following functional units:
User input = 55, User output = 35, User Enquiries = 40, User Files = 8, External Interfaces = 5.
Assume complexity adjustment factors are significantly complex and weighting factors are high.
Calculate the functional point for the project.