Upload
damairiawan-desta-wiriatma
View
218
Download
0
Embed Size (px)
Citation preview
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 1/22
Program DesignProgram DesignDamairiawan Desta (32384)
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 2/22
ObjectiveObjective
y To describe the steps in the program
development process
y To introduce current program design
methodology
y To introduce procedural and object-
oriented programming
y To introduce algorithms and pseudocode
y To describe program data
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 3/22
7 Steps in Program Development7 Steps in Program Development
1. Define the problem
2. Outline the situation
3.Develop the outline into algorithm
4. Test the algorithm
5. Code the algorithm
6. Run the program7. Document and maintain the program
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 4/22
Program Design MethodProgram Design Method
y procedure-driven
y event-driven
y
data-driven.
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 5/22
ProcedureProcedure--driven program designdriven program design
y Based on the idea that the most
important feature of a program is 'what' it
does
y 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.
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 6/22
EventEvent--driven program designdriven program design
y 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.
y The initial state of a program is identified,
then all the triggers that represent valid
events for that state are established.
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 7/22
DataData--driven program designdriven program design
y Based on the idea that the data in a
program is more stable than the
processes involved.
y It begins with an analysis of the data and
the relationships between the data, in
order to determine the fundamental data
structures.
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 8/22
What is an algorithm? What is an algorithm?
y An algorithm is like a recipe: it lists the
steps involved in accomplishing a task.
y It can be defined in programming terms as
a set of detailed, unambiguous an ordered
instructions developed to describe the
processes necessary to produce the
desired output from a given inputy The algorithm is written in simple English
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 9/22
y An algorithm must:
be lucid, precise and unambiguous
give the correct solution in all cases
eventually end.
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 10/22
What is What is pseudocodepseudocode??
y Pseudocode is really structured English. It
is English that has been formalized an
abbreviated to look like high-level
computer languages.
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 11/22
y Statements are written in simple English.
y Each instruction is written on a separateline.
y Keywords and indentation are used tosignify particular control structures.
y Each set of instructions is written from
top to bottom, with only one entry andone exit.
y Groups of statements may be formed intomodules, and that group given a name.
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 12/22
Program dataProgram data
Three main discussion:
y Variables
Is the name given to a collection of memory cell,designed to store particular data item. The valuestored may change or vary as the program executes.
y Constants
Is a data item with a name and a value that remain thesame during the execution of the program.
y Literals Is a constant whose name is the writte representation
of its value.
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 13/22
Data TypesData Types
y Should be clearly defined at the beginning
of the program.
y Can be:
Elementary data items
Data structures
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 14/22
Elementary Data ItemElementary Data Item
y Contain single variable that is always
treated as a unit.
y Usually classified into data types.
y A data type consists of a set of data
values and a set of
y operation that can be performed on
those values.
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 15/22
The most common elementary data types:The most common elementary data types:
y Integer : representing a set of whole numbers,positive, negative or zero. e.g. 3, 576, -5
y Real : representing a set of numbers, positive ornegative, which may include values before or aftera decimal point. Sometimes referred to as floatingpoint numbers. e.g. 19.2, 1.92E+01, -0.01
y Character : representing the set of characters onthe keyboard, plus some special characters. e.g. ¶A·,
¶b·, ¶$·y Boolean : representing a control flag or switch,
which may contain one of only two possiblevalues; true or false.
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 16/22
Data StructuresData Structures
y Is an aggregate of other data items.
y Its component could be elementary data
items or another data structure.
y Data is grouped together in a particular
way to reflects the situation with which
the program is concerned.
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 17/22
The most common Data StructuresThe most common Data Structures
y Record: a collection of data items or fields that allbear some relationship to one another.
example: a student record; may contain the student¶snumber, name, address and enrolled subjects.
y File: a collection of records. example: a student file; may contain a collection of the
above student records.
y String: a collection of characters that can be fixed
or variable. Example: the string ´Si Bhe´may represent a student¶s
name.
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 18/22
y Array: a data structure that is made up of
a number of variables or data items that
all have the same data type and are
accessed by the same name. Example: an array called ¶scores· may contain a
collection of students¶ exam scores.
Access to the individual items in the array ismade by the use of an index or subscript
beside the name of the array scores[3]
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 19/22
FilesFiles
y A popular method of storing informationis to enter and store data on a file.
y The ma jor advantages of using files are:
Several different programs can access thesame data.
The data can be entered and reused severaltimes.
The data can be easily updated andmaintained.
The accuracy of the data is easier to enforce.
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 21/22
DataValidationDataValidation
y Data should always undergo a validation
check before it is processed by a
program.
y Different types of data require different
checks ² for example:
8/6/2019 1 Program Design
http://slidepdf.com/reader/full/1-program-design 22/22
y Correct type: the input data should match the data type
definition stated at the beginning of the program.
y Correct range: the input should be within a required set
of values.
y Correct length: the input data should be the correct
length.
y Completeness: all required fields should be present.
y Correct date: an incoming data should be acceptable.