SW Design
SW Design
SW Design
– Object – oriented
– Function – oriented/ Structured Design
Function – oriented Design
The design consists of
• Module definitions with each module supporting a functional
abstraction
• The system is viewed as a transformation function,
transforming the inputs to the desired output.
• The output from the design phase following function-oriented
approach are
– The definition of all the major data structures in the system
– All the modules of the system
– How the modules interact with each other
Concept of a module –
A module is a software component with parts, at any
level of abstraction.
At the highest level of abstraction, an entire system is a
module whose immediate parts are the sub-systems
of which it is composed. In other words, a system is a
module whose parts are its architectural components.
Modularization
Modularization is the process of dividing a software
system into multiple independent modules where each
module works independently.
Modularity
A system is modular if it is composed of well-defined,
conceptually simple and independent units interacting
through well-defined interfaces.
Advantages of a Modular System
– are easier to understand
– Are easier to document
– Programming individual modules are easier because the programmer
can focus on just one small , simple problem rather than a large
complex problem.
– Testing and debugging becomes easier
– Modules can be reusable
– Changes to the system can be made easily
Module Coupling
• Coupling is a measure of degree of independence
between modules.
• When the interaction between two modules is too
little, the modules are described as loosely coupled
modules
• When there is a high degree of interaction the
modules are described as tightly coupled modules
• Good design requirement –
– Modules should loosely coupled. i.e. should kept as
independent as possible.
As 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
• Data Coupling
• Stamp Coupling
• Control Coupling
• External Coupling
• Common Coupling
• Content Coupling
Data Coupling
• Functional Cohesion
• Sequential Cohesion
• Communicational Cohesion
• Procedural Cohesion
• Temporal Cohesion
• Logical Cohesion
• Coincidental Cohesion
Functional Cohesion
• The name of the module will indicate its function
• All statements within a module are based on one function.
• It is the best cohesion
Ex- CALCULATE_SALES_TAX
IF PRODUCT IS SALES_TAX EXEMPT THEN
SALES_TAX = 0
ELSE
IF PRODUCT_PRICE <100 THEN
SALES_TAX = PRODUCT_PRICE * 0.25
ELSE
SALES_TAX = PRODUCT_PRICE * 0.35
ENDIF
ENDIF
Sequential Cohesion
• The instructions inside a module are related to each other
thorough the input data.
• The output from first instruction becomes input to the
second and so on.
• Sequence of events is very important.
Ex – TOTAL_PURCHASES =0
READ NO_OF_PURCHASES
DO LOOP_INDEX = 1 TO NO_OF_PURCHASES
GET PURCHASES
ADD PURCHASES TO TOTAL_PURCHASES
ENDDO
SALES_TAX = TOTAL_PURCHASES * SALES_TAX_PERCENTAGES
AMT_DUE = TOTAL_PURCHASES + SALES_TAX
END
Communicational Cohesion
• The activities are related to each other by the data that the modules
uses.
• Sequence is not important
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
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 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
Coupling & Cohesion
Cohesion Coupling
Cohesion is the concept of intra Coupling is the concept of inter
module. module.
Cohesion represents the relationship Coupling represents the relationships
within module. between modules.
Increasing in cohesion is good for Increasing in coupling is avoided for
software. software.
Cohesion represents the functional Coupling represents the
strength of modules independence among modules.
Highly cohesive gives the best Loosely coupling gives the best
software. software.
Structure Charts
• For a function-oriented design, the design can be represented
graphically by structure charts.
• Structure Chart represent hierarchical structure of modules.
• It breaks down the entire system into lowest functional modules,
describe functions and sub-functions of each module of a
system to a greater detail.
Main
sum
a, n a, n a
a,n
B C D B C D
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
Flow Chart Example
Draw a flow chart to test
Start
whether a person is
eligible for voting or not.
Enter Age
Is Age Eligible
Eligible >= 18
Start
Pseudo Code
• A pseudo code is a technique for structured program design that uses
English like statements to outline the logic of a program.
• An alternative to flowchart is pseudo code.
• This structured technique uses English like statements in place of the
flowchart's graphic symbols.
• Pseudo code looks more like a program than a flowchart
• it's often easier to code a program from pseudo code than from a
flowchart,
• unlike a flowchart, pseudo code is relatively easy to modify and can be
embedded into the program as comments.
Example Pseudo Code
The name of the class is typically written in the top compartment of the class
box and is centered and bold.
2. Attributes:
Attributes, also known as properties or fields, represent the data members of
the class. They are listed in the second compartment of the class box and
often include the visibility (e.g., public, private) and the data type of each
attribute.
3. Methods:
Methods, also known as functions or operations, represent the behavior or
functionality of the class. They are listed in the third compartment of the class box
and include the visibility (e.g., public, private), return type, and parameters of each
method.
4. Visibility Notation:
Visibility notations indicate the access level of attributes and methods. Common
visibility notations include:
Class A Class B
Association Example
• Inheritance (or Generalization):
– Represents an "is-a"
relationship.
– An abstract class name is
shown in italics.
– SubClass1 and SubClass2 are
specializations of Super Class.
– A solid line with a hollow
arrowhead that point from the
child to the parent class
Generalization(Inheritance)
• Aggregation:
$ Dollar Sign
INVENTORY REPORT DATE : DD/MM/YYYY
Total 9999999999.99
User Interface Design
User Interface
Date : 02/09/09
Sales Tax 20
Grand Total
220
Spinner
Window
That’s all folks!