Creating Computer Programs - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

Creating Computer Programs

Description:

Title: PowerPoint Presentation Author: Chuck Schuler Last modified by: Dave Kunkler Created Date: 7/21/2000 1:16:22 PM Document presentation format – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 22
Provided by: Chuc120
Category:

less

Transcript and Presenter's Notes

Title: Creating Computer Programs


1
lesson 27
Creating Computer Programs
2
  • This lesson includes the following sections
  • What is a Computer Program?
  • How Programs Solve Problems
  • Two Approaches Structured
  • Object-Oriented Programming

3
What is a Computer Program?
  • Files
  • Hardware/Software Interaction

4
What is a Computer Program? - Files
Typically, a program is stored as a collection
of files. Some common file types used in
programs are
  • Executable (.EXE) files actually send commands to
    the processor.
  • Dynamic Link Library (.DLL) files are partial
    .EXE files.
  • Initialization (.INI) files contain configuration
    information for a program.
  • Help (.HLP) files contain information for the
    user.


5
What is a Computer Program? - Hardware/Software
Interaction
  • The program tells the CPU to process interrupts,
    or sets of steps the CPU must follow to perform a
    task.
  • To control hardware, a program must be written in
    binary numbers (1s and 0s). This code is called
    machine code or machine language.
  • Programmers use programming languages to write
    code in nearly human language. The resulting
    description is called source code.
  • Compilers and interpreters translate a program
    into object code, the binary version of source
    code.


6
How Programs Solve Problems
  • Program Control Flow
  • Algorithms
  • Heuristics
  • Common Flow Patterns
  • Variables and Functions



7
How Programs Solve Problems Program Control
Flow
  • The order in which program statements are
    executed is called program control flow.
  • To determine program control flow, programmers
    may use a flowchart to map the program's
    sequence.
  • Programmers may also create a simple text version
    of a program's code called pseudocode to
    determine how the program will flow.


8
This flowchart shows that the sequence can vary
depending on conditions.
9
How Programs Solve Problems - Algorithms
  • An algorithm is a set of steps that always lead
    to a solution. The steps are always the same,
    whether the problem is being solved manually or
    with a PC.
  • A computer program may contain thousands of
    algorithms, each one devoted to a single task.
  • An algorithm, for example, will find the highest
    point in a mountain range by comparing all the
    points until the highest one is found.


10
no
11
How Programs Solve Problems - Heuristics
  • If a problem is too complex to be solved by an
    algorithm, a programmer may try to solve it by
    using heuristics.
  • Heuristics are like algorithms, and will always
    find a solution to a problem. But unlike
    algorithms, heuristics are not guaranteed to find
    the best possible solution.
  • A heuristic, for example, may find the highest
    point in a mountain range by comparing random
    points, but this process may never find the
    highest one.

12
(No Transcript)
13
How Programs Solve Problems - Common Flow
Patterns
  • To determine when and where to pass program
    control, a developer may use conditional
    statements or loops.
  • A conditional statement determines whether a
    condition is true. If so, control flows to the
    next part of the program.
  • A loop repeats again and again until a condition
    is met. Control then passes to another part of
    the program.

14
(No Transcript)
15
How Programs Solve Problems - Variables and
Functions
  • A variable is a named placeholder for data that
    is being processed. Programs contain variables
    to hold inputs from users, for example.
  • A function is a set of steps that are followed to
    perform a specific task. By assembling a
    collection of functions together, a developer can
    build a complete program.

16
Two Approaches Structured Object-Oriented
Programming
  • Early programmers allowed control to pass from
    one part of a program to another by using goto
    statements. Control would "go to" a different
    part of the program when conditions allowed.
  • Goto statements cause programs to become very
    complex. To eliminate their use, programmers
    developed two approaches to development
  • Structured programming
  • Object-oriented programming

17
This type of programming has fallen into disfavor.
18
Two Approaches Structured Object-Oriented
Programming - Structured Programming
Structured programming uses three types of
control structures to make program control flow
more predictable
  • Sequence structure defines the default control
    flow.
  • Selection structures are built around conditional
    statements.
  • Repetition (looping) structures use loops, which
    execute according to the results of conditional
    statements.

19
(No Transcript)
20
Two Approaches Structured Object-Oriented
Programming - Object-Oriented Programming
  • In object-oriented programming (OOP), programs
    are built from blocks of code, called objects.
    Each object has functions and characteristics
    (attributes), and can contain (encapsulate) other
    objects.
  • Objects that share common attributes can be
    grouped into classes. Classes can be divided
    into subclasses.
  • In OOP, objects communicate with one another by
    exchanging messages.

21
lesson 27 Review
  • Define the term computer program.
  • Describe the use of flowcharts and pseudocode in
    programming.
  • Identify two ways in which a program can work
    toward a solution.
  • Differentiate the two main approaches to computer
    programming.
  • List and describe three elements of
    object-oriented programming.

Write a Comment
User Comments (0)
About PowerShow.com