Lecture Notes 82503 - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Lecture Notes 82503

Description:

Most popular analogy is a recipe. Like a recipe, you follow a well-defined series of steps to achieve desired results. ... If it flies, you get to enjoy watching it. ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 20
Provided by: tyjo
Category:
Tags: flies | lecture | notes

less

Transcript and Presenter's Notes

Title: Lecture Notes 82503


1
Lecture Notes 8/25/03
  • Program Design

2
Algorithms
  • What is an algorithm
  • Most popular analogy is a recipe.
  • Like a recipe, you follow a well-defined series
    of steps to achieve desired results.
  • Example
  • How do you start your car?

3
Algorithms Cont
  • Without knowing it, most people have an algorithm
    for starting their car.
  • Unlock door
  • Open door
  • Sit in drivers seat
  • Insert key into ignition
  • Check mascara in rear-view mirror
  • Turn key and hold until car is started.

4
Steps in Program Development
  • 1) Define the problem
  • Basically any program can be looked at like a
    black box.

5
Steps in Program Development...
  • Outline the solution
  • Here we delve into the black box. Once we know
    what we need to do, its time to start designing
    a solution.
  • The outline may include
  • Major processing steps involved
  • Major subtasks
  • Major Control structures (e.g. Repetition loops)
  • Major variables and record structures
  • The mainline logic

6
Steps in Program Development
  • Develop the outline into an algorithm
  • The algorithm should represent the precise steps
    to be taken and the order in which they should be
    carried out.
  • For this class, algorithmpsuedocode
  • We will be covering psuedocode over the next 2-3
    lectures Fun fun fun!!!!

7
Steps in Program Development
  • Test the algorithm for correctness.
  • Run through the psuedocode and make sure it makes
    sense.
  • Example
  • Start your car
  • Unlock door
  • Open door
  • Sit in drivers seat
  • Put Car in reverse
  • Place brick on accelerator
  • Turn key and dive out of drivers side window

8
Steps in Program Development
  • Code the algorithm into a specific programming
    language.
  • C
  • C
  • Java
  • Perl
  • Fortran
  • Cobol
  • Etc

9
Steps in Program Development
  • Run the program on the computer
  • Here we can detect the two main types of errors.
  • Syntax errors (program wont run)
  • Logic errors (program runs but doesnt work
    properly)
  • This step can be quite fun.
  • Its analogous to building a model rocket. You
    put it all together, but you really dont know
    what will happen until you light the fuse.
  • If it flies, you get to enjoy watching it.
  • If it doesnt, you get to try to figure out why
    (hopefully without blowing your fingers off).

10
Steps in Program Development
  • Document and maintain the program
  • The two main types of documentation are
  • External (algorithm, test data results, etc)
  • Internal (commenting your code)

11
Stuctured Programming
  • Top Down Development
  • Instead of jumping right in, programmers have
    found that using a more systematic approach is
    much more powerful.
  • We look at major tasks and break those tasks into
    subtasks,
  • Then we break the subtasks into further subtasks.
  • We repeat until the subtasks are manageable.

12
Structured Programming
  • Modular Design
  • Subtasks are often repeated. So it is useful to
    modularize them so that we dont have to reinvent
    the wheel every time we need to do the same
    subtask.
  • Example. Filling out paper-work for a new job.
  • Honestly, how many times do you need to write
    your name and address, and then sign a piece of
    paper!?

13
Structured Programming
  • Structure theorem
  • Any computer program can be written using the
    following three basic control structures
  • Sequence
  • Selection (If-Then-Else)
  • Repetition (DoWhile)

14
Psuedocode
  • This book establishes a standard for psuedocode
    which we will follow in this class.
  • Note There really is no standard for psuedocode
    that everyone knows or follows

15
Pseudocode
  • Five standards this book follows
  • Statements are written in simple english
  • Each instruction is written on a separate line.
  • 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 that group given a name.

16
Program Data
  • Variables, constants, and literals
  • Variables
  • Names given to represent data. That data can be
    manipulated and changed.
  • Constants
  • Names given to represent data. That data CANNOT
    be manipulated or changed.
  • Literals
  • Basically, a constant whose name is the written
    representation of its value.

17
Elementary Data Items
  • This is what we will deal with for most of the
    semester.
  • One value is represented as one of the
    aforementioned types of program data.
  • E.g. The integer 10 may be represented one of
    three ways
  • Ten (variable)
  • Ten (constant)
  • 10

18
Data Structures
  • The only data structures we will cover in this
    class are
  • File
  • Array
  • String
  • In CS 202, record data structures are covered.
    These are things like structs and classes.

19
Summary
  • Now that were all utterly confused -)
  • This lecture is simply an introduction to some
    ideas.
  • At this point, you are not really expected to
    know anything about programming. I just want to
    get you thinking about how we really go about
    problem solving.
  • Read Chapters 1 2 in Simple Program Design.
Write a Comment
User Comments (0)
About PowerShow.com