Program design
Program design
Program design
The program design is the process that an organization uses to develop a program. It is most
often an iterative process involving research, consultation, initial design, testing, and
redesign.
A program design is the plan of action that results from that process.
● Top – Down
● Bottom-Up
● Data-Driven
Top-Down Design Model:
Top down Approach
(a) The large program is divided into many small module or subprogram or function or
procedure from top to bottom.
(b) At first supervisor program is identified to control other sub modules. Main modules are
divided into sub modules, sub-modules into sub- sub- modules. The decomposition of
modules is continuing whenever desired module level is not obtained.
(c) Top module is tested first, and then sub-modules are combined one by one and tested.
Example: The main program is divided into sub-program A, B, and C. The A is divided into
subprogram A1, A2 and A3.The B is into B1, and B2. Just like these subprograms, C is also
divided into three subprogram C1, C2 and C3. The solution of Main program is obtained from
sub program A, B and C.
• In software designing, only pure top down or Bottom up approach is not used. The
hybrid type of approach is recommended by many designers in which top down and
bottom up, both approaches are utilized.
Data-driven approach
When doing data-driven programming, one clearly distinguishes code from the data structures
on which it acts and designs both so that one can make changes to the logic of the program by
editing not the code but the data structure.
Data-driven programming is sometimes confused with object-orientation, another style in
which data organization is supposed to be central. There are at least two differences. One is
that in data-driven programming, the data is not merely the state of some object, but defines
the control flow of the program. Where the primary concern in OO is encapsulation, the primary
concern in data-driven programming is writing as little fixed code as possible. Unix has a
stronger tradition of data-driven programming than OO.
Programming data-driven style is also sometimes confused with writing state machines. It is,
in fact, possible to express the logic of a state machine as a table or data structure, but hand
coded state machines are usually rigid blocks of code that are far harder to modify than a table.
An important rule when doing any kind of code generation or data-driven programming is this:
always push problems upstream. Don't hack the generated code or any intermediate
representations by hand — instead, think of a way to improve or replace your translation tool.
Otherwise, you're likely to find that hand-patching bits that should have been generated
correctly by the machine will have turned into an infinite time sink.
Flowchart
The pictorial presentation of program is called Flowchart. It is a tool and technique to find out
solution of programming problems through some special symbols. It is a way to represent
program using geometrical patterns. Prior to 1964, every manufactures use different types of
symbols, there was no uniformity and standards of flowcharting. The Standard symbols were
developed by American Standard National Institute (ANSI).
(i) Start / Stop: This oval is used to represent START and STOP of program.
(ii) Input/Output: Parallelogram is used to denote input and output of data. We take data
through it and display result also using this symbol.
(iii) Process: Rectangle is used to denote process, formula, increment, and decrement and
assigned value also.
(iv) Pre-defined Process: The predefined process is denoted by this symbol. Example: Sorting
and Display is pre-defined process and represented as:
Pre-defined Process
(iv) Decision box: It is a symbol of decision. All type of decisions is written in it.
(vi) Data flow: It is used to show data flow from one component to other component, one
process to other and one symbol to other symbol.
The John Von Neumann used flowchart to solve problem in 1945 and explained its importance
in program designing.
Illustration: In our everyday life, there is a sequence of works. These sequences of works are
called routine. We all are tied with it. Suppose, we arise early in the morning at 5 0‘ clock, go to
toilet, after coming from toilet, clean hands with soap and water, brush our teeth then take bath.
Here, one sequence of work is formed.
In computer world, programming language is used to solve certain problems. The solution of
problem is a sequence of processes. In one problem, there may be many processes, the flowchart
help to arrange processes in definite order. Suppose, we have to convert Fahrenheit temperature
into Celsius, it has following five steps:
• Step-1: Start
• Step-2: Enter Fahrenheit temperature (F)
• Step-3: Application of formula: C=(F-32)(5/9)
• Step-4: Displaying the result (C)
• Step-5: Stop
These types of processes involved in solution of problem are called Algorithm. It is a stepwise
presentation of problem solution in simple English without using confusing words and phrases.
Flow Chart
Flowchart is like as city map. Travelers or tourists search places of historical importance through
city map. Buildings are built on the basis of building-design (map) drawn by Architect
engineers.
Just like it, program is coded on the basis of flowchart. Flowchart is a language free concept, if it
is prepared, any language can be used for program coding. In software development cycle,
flowcharting is one essential phase.
System Flowchart:
System flowchart is a pictorial representation of procedure flows inside and outside of the
systems. It is also called Data Flow Chart or Procedure Chart.
(i) Manual Input: It is used to enter data manually. For example, keyboard is a manual input
device.
(v) Display: This is a symbol for online display, Example: Monitor (VDU).
Compilation Process
Problem-3: The headquarter of ABC Private Ltd. is linked with production, marketing and sale
department. The day-by-day information of each department is compiled at headquarter, stored
in master file and report is given to higher authority of company.
2. Algorithm
Algorithm is a stepwise presentation of procedures of program in simple and phraseless English.
It is also a programming tools used by programmer to develop software. It is a logical
representation of program procedures in order to obtain result. So, sometimes, it is called
Procedure also. An algorithm, named after the ninth Centaury scholar Abu Jafar Muhammad
Ibn Musa Al-Khowarizmi of Bagdad (Iraq).
complete, unambiguous, step-by-step procedure for carrying out the task. Such a procedure is
called an ‖Algorithm―. An algorithm is not same as program. An algorithm is more like the
idea behind the program.
• Language independent
• Simple, complete, unambiguous, step-by-step program flow
• no standard format or syntax for the algorithm
• helpful to understand problems and plan out solution
• Step-1: Start
• Step-2: Read a,b and c
• Step-3: d=b*b-4*a*c
• Step-4: if D<0, root is imaginary
• Step-5: x1 = (-b + sqrt (D))/(2*a)
X2=(-b-sqrt(D))/(2*a)
Example: Write an algorithm to find out area of triangle when sides are given.
Algorithm:
Step-1: start
Step-3: S=(a+b+c)/2
Step-4: A=sqrt((s-a)(s-b)(s-c))
Step-5: Display A
Step-6: Stop
Example: Write an algorithm to find out slop and mid point of coordinate.
Algorithm:
Step-1: Start
Step-3: Slop=(y2-y1)/(x2-x1)
Step-4: x-(x1+x2)/2
Step-6: Stop
There are no standard rule for algorithm designing, but we can use some common rules which
are not ambiguous to another computer literates:
(b) Conditional statements: if -endif and if –else-end-if are used for conditions.
Example:
Endif
statement(s) endfor
Fact = 1
Read number
Endfor
End
Problem-1: Draw a flow chart to input two numbers and display sum.
Problem-2: Draw a flowchart to enter principal,rate and time and display simple interest.
Solution,
(c) Phrase less statements, contains noun and simple verb of English , and
It is a Program Design Language (PDL) provides skeleton for program design and it can
replace flowchart used to describe system design.
(i) Imperative Sentence: The imperative sentences are used to show actions.
(ii) Operators: Mostly arithmetic operators (+, -, *, / etc) and relational operators (=, =>, =>, <,
> etc.) are used.
(iii) Decision: IF, THEN, ELSE, ENDIF, CASE, ENDCASE are used for decision-making.
Example:
CASE (choice)
ENDCASE.
(iv) Looping: The looping or repetition of statements is shown by FOR, FOR DO, ENDFOR,
DO, DO WHILE, DO UNTIL, ENDDO etc.
Example:
ENDFOR.
Example:
IF age >=18
ELSE
WAIT until age is not 18
ENDIF
BEGIN
WRITE a letter
IF bicycle is available
ELSE
ENDIF
BUY a stamp
END.
Decision Tables
A Decision table represents conditions and the respective actions to be taken to address
them, in a structured tabular format. It provides a visual and systematic method for
documenting various combinations of inputs and their corresponding outcomes or
actions.
It is a powerful tool to debug and prevent errors. It helps group similar information into
a single table and then by combining tables it delivers easy and convenient
decisionmaking. Decision tables are often used in decision support systems, business
analysis, and rule-based systems to clarify and manage complex decision-making
processes.
Rules: These are the possible combinations of conditions and describe the
actions or outcomes associated with those combinations. Rules are usually
presented as rows in the decision table.
Actions: Actions specify what should be done or the result that should be
achieved for each combination of conditions.
To create the decision table, the developer must follow the basic four steps:
Good credit Sufficient income Loan term < 5 years Approve Loan
● There are three conditions: "Condition 1" represents the credit score of the
applicant, "Condition 2" represents the applicant's income, and "Condition 3"
represents the requested loan term.
● There are five rules, each representing a combination of conditions, and each rule
has an associated action. For example, the first rule states that if the applicant has
good credit, sufficient income, and a loan term of less than 5 years, the action is to
"Approve Loan."
● The last four rules state that if certain conditions are met, the action is to "Decline
Loan."
This decision table helps in making loan approval decisions based on a set of conditions and
their combinations. It provides a clear and structured way to document the decision rules,
making it easier for decision-makers to understand and implement the rules within a system.
Decision tables can be more complex, involving a larger number of conditions and rules, and
they are particularly useful when dealing with complex business logic or decision-making
processes.
Decision Tree
The tree like presentation of condition and actions are called decision tree. Every node denotes
conditions. It is used for logical variations and problems involving few complex decisions with
complex branching routines.
Example: The person which age is greater or equal to 18 can caste vote in the favour of his
leader otherwise has to wait until age of 18. There is two conditions (a)age<18, and (b)age>=18,
both the conditions have actions.
Decision Tree
Example: The hotel ABC offers new discount scheme foe university students. It
provides 15% and 10% discount to monthly customers for vegetarian and non-vegetarian
meal respectively. The student attend hotel occasionally have discount rate 10% and 5%
for vegetarian and nonvegetarian meal.
They help visualize the structure of the database, including the entities (tables), attributes
(columns), and the relationships between them.
ERDs use specific symbols and notations to represent different components of the database:
Attributes (Columns): Attributes are depicted within the entities and are used to
describe the properties or characteristics of each entity. For example, a "Customers"
entity may have attributes like "CustomerID," "Name," and "Email."
Cardinality: Cardinality notation indicates how many instances of one entity are
related to how many instances of another entity in a relationship. Common
cardinalities include "1" for one instance and "N" for many instances.
Assessment
What is the difference between Top-Down and Bottom-Up program design approaches?
What is the difference between pseudocode and flowchart program design tools?
Write a structured algorithm that would prompt the user to enter the Length and Width of a
rectangle, calculate the Area and Perimeter, then display the result.