0% found this document useful (0 votes)
21 views

20180728113008D1526 - Session 01 Program Design, Pseudocode, and Developing An Algorithm L

This document provides an overview of program design methods. It discusses the steps in program development which include defining the problem, designing an algorithmic solution, and checking the solution. It also covers key concepts like procedural versus object-oriented programming, algorithms, pseudocode, variables, data types, and the three basic control structures of sequence, selection, and repetition. The goal is to explain the fundamentals of program design methodology and preparing students to design algorithms and represent them using pseudocode.

Uploaded by

raksiyt2001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

20180728113008D1526 - Session 01 Program Design, Pseudocode, and Developing An Algorithm L

This document provides an overview of program design methods. It discusses the steps in program development which include defining the problem, designing an algorithmic solution, and checking the solution. It also covers key concepts like procedural versus object-oriented programming, algorithms, pseudocode, variables, data types, and the three basic control structures of sequence, selection, and repetition. The goal is to explain the fundamentals of program design methodology and preparing students to design algorithms and represent them using pseudocode.

Uploaded by

raksiyt2001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 34

Course : Program Design Methods

Effective Period : July 2018

Program Design,
Pseudocode, and Developing
an Algorithm

Session 01
(Lecture)
Acknowledgement

These slides have been adapted from


Simple Program Design : A Step by Step
Approach, Lesley Anne Robertson, Fifth
Edition,
Course Technology. ISBN: 978-1-4239-0132-7.
Chapter 1 - 3
Learning Objectives

LO 1 : Explain program design method


Contents
• Steps in Program Development
• Program Design Methodology
• Procedural versus Object – Oriented
Programming
• An Introduction to Algorithms and Pseudocode
• Program Data
• How to Write Pseudocode
• Meaningful Names
• The Structure Theorem
• Defining the Problem
• Designing a Solution Algorithm
• Checking the Solution Algorithm
Steps in Program Development
Steps in Program
Development
Program Design Methodology
Program Design
Methodology
• The fundamental principle of program design
is based on the fact that a program accepts
input data, processes that data, and then
delivers the data to the program user as
output
• The most common approaches are :
Procedure – driven
Event – driven
Data – driven
Procedure Driven Program Design

• Based on the idea that the most important


feature of a program is what it does – its
processes or functions
• the flow of data into and out of each
process or function is then considered and
a strategy developed to break each function
into smaller and more specific
• The details about the actual structure of the
data are not considered until all the high-
level processes or functions of the program
have been defined
Event Driven Program Design
• Based on the idea that an event or
interaction with the outside world can
cause a program to change from one
known state to another
• The initial state of a program is identified,
the all the triggers that represent valid
events for that state are established
• Each of these events results in the
program changing to a new defined state,
where it stays until the next event occurs
Data Driven Program Design
• Based on the idea that the data in a program
is more stable that the processes involved
• It begins with an analysis of the data and the
relationship between the data, in order to
determine the fundamental data structures.
• Once the data structures have been defined,
the required data outputs are examined in
order to establish what processes are
required to convert the input data to the
required output
Procedural vs Object Oriented
Programming
Procedural Programming

• Based on a structured, top – down


approach to writing effective programs
• The approach concentrate on what a
program has to do and involves identifying
and organizing the processes in the
program solution
• The problem is usually broken down into
separate tasks or functions and includes
top – down development and modular
design
Object Oriented Programming
• Object oriented programming is also
based on breaking down the problem, but
the primary focus in on the things (or
objects) that make up the program
• The program is concerned with how the
objects behave, so it breaks the problem
into a set of separate objects that perform
actions and relate to each other. These
objects have definite properties and each
object is responsible for carrying out a
series of related tasks
An Introduction to Algorithms and
Pseudocode
What is an Algorithm?
• The term “algorithm” is taken from the name
of a mathematician named Al-Khwarizmi
• Algorithm consist of needed steps to
accomplish a task
• The algorithm is written in simple English
and is not a formal document.
• An algorithm must :
– Be lucid, precise and unambiguous
– Give the correct solution in all cases
– Eventually end
Example of an Algorithm
• Example: instruct someone to add up a list
of prices on a pocket calculator
turn on calculator
clear calculator
repeat the following instructions
key in dollar amount
key in decimal point (.)
key in cents amount
press addition (+) key
until all prices have been entered
write down total price
turn off calculator
What is Pseudocode ?
• Pseudocode is used to represent the algorithm
• The common characteristics of pseudocode :
– Statements are written in simple English
– Each instructions is written on a separate line
– Keywords and indentation are used to signify
particular control structures
– Each set of instructions is written from top to
bottom, with only one entry and one exit
– Groups of statements may be formed into
modules, and the module given a name
Program Data
Variables, Constants and Literals
• Variable :
– A collection of memory cells designed to store a
particular data item
– It is called a variable because the value stroed
in those memory cells may change pr vary as
program executes
• Constant :
– A data item with a name and a value that
remain the same during the execution of the
program
• Literal :
– A constant whose name is the written
representations of its value
Data Types
• Data Types :
– Elementary Data Items :
• Integer
• Real
• Character
• Boolean
– Data Structures
• Record
• File
• Array
• String
How to Write Pseudocode
Six Basic Computer Operations
1. A computer can receive information
2. A computer can put out information
3. A computer can perform arithmetic
4. A computer can assign a value to a
variable or memory location
5. A computer can compare two variables
and select one of two alternative
actions
6. A computer can repeat a group of
actions
Meaningful Name
Meaningful Name
• When designing a solution algorithm, a
programmer must introduce some
unique name, which will be used to
represent the variables or objects in the
problem. The name itself should be
transparent enough to adequate describe
the variable
• All names should be meaningful
The Structure Theorem
The Structure Theorem
• The structure theorem states that it is
possible to write any computer program
using only three control structure :
– Sequence : is the straightforward execution
of one processing step after another
– Selection : is the presentation of a
condition and the choice between two
actions, the choice depending on whether
the condition is true or false
– Repetition : is the presentation of a set of
instructions to be performed repeatedly.
Developing an Algorithm
Defining the Problem
• Defining the problem involves carefully
reading and rereading the problem until
understand completely what is required
• To help with this initial analysis, the problem
should be divided into three separate
components
– Input : a list of the source data provided
to the problem
– Output : a list of the outputs required
– Processing : a list of actions needed to
produce the required outputs
Designing a Solution Algorithm

• Once the problem has been properly


defined, the next step will be outline the
solution
• Pseudocode is useful present the solution
algorithm
Checking the Solution
Algorithm
• After a solution algorithm has been
established, it must be tested for
correctness
• Desk checking involves tracing through the
logic of the algorithm with some chosen
test data. That is, “walk” through the logic
of the algorithm exactly as a computer
would, keeping track of all major variable
values on a sheet of paper
Checking the Solution
Algorithm
There are six simple steps to follow when desk checking an
algorithm:
1. Choose simple input test cases that are valid. Two or
three test cases are usually sufficient
2. Establish what the expected result should be for each
test case
3. Make a table on a piece of paper of the relevant variable
names within the algorithm
4. Walk the first test case through the algorithm, line by
line, keeping a step – by – step record of the contents of
each variable in the table as the data passes through the
logic
5. Repeat the walk-through process using the other test
data cases, until the algorithm has reached its logical end
6. Check that the expected result established in step 2
matches the actual result developed in step 5
References
• Simple Program Design : A Step by Step Approach.,
Lesley Anne Robertson, Fifth Edition,
Course Technology. ISBN: 978-1-4239-0132-7.
• The Structured Theorem,
http://www.docstoc.com/docs/4530185/Developing-an-
Algorithm-The-Structure-Theorem-The-Structured-
Theorem
• Vague Pseudocode Examples,
http://users.csc.calpoly.edu/~jdalbey/SWE/pdl_vague.ht
ml
• Object Oriented Overview,
http://www.tutorialspoint.com/uml/uml_quick_guide.ht
m/SWE/pdl_vague.html
Q&A

You might also like