Computers: Tools for an Information Age - PowerPoint PPT Presentation

1 / 30
About This Presentation
Title:

Computers: Tools for an Information Age

Description:

Telling the Computer What to Do. 2. Objectives ... int Feet, Inches; Feet = 6; Inches = Feet * 12; cout ... A Typical Program (convert feet to inches) ... – PowerPoint PPT presentation

Number of Views:99
Avg rating:3.0/5.0
Slides: 31
Provided by: jian9
Category:

less

Transcript and Presenter's Notes

Title: Computers: Tools for an Information Age


1
ComputersTools for an Information Age
  • Chapter 15
  • Programming and Languages
  • Telling the Computer What to Do

2
Objectives
  • Explain how to define a problem, plan the
    solution, and then code, compile, debug, and
    document the program
  • List and describe the levels of programming
    languages machine, assembly, high level, very
    high level, and natural
  • Describe the major programming languages that are
    in use today
  • Explain the concepts of object-oriented
    programming

3
Programming
  • Program a set of detailed, step-by-step
    instructions that directs the computer to do what
    you want it to do
  • Programming language an artificial language
    that defines a set of rules (syntax) used to
    generate or to express computer programs

4
A Typical Program (convert feet to inches)
include ltiostreamgt int main () int
Feet, Inches Feet 6 Inches Feet
12 cout ltlt Height is " ltlt Inches ltlt "in. ltlt
endl return 0 // end main
5
The Programming Process
  • Five main steps
  • Defining the problem
  • Planning the solution
  • Coding the program
  • Testing the program
  • Documenting the program

6
Defining the Problem
  • Develop a written agreement that specifies
  • The input data
  • The desired output
  • The processing required to convert
  • Sometimes, the programmer receives a written
    specification from the systems analyst
  • Other times, the programmer meets with users
    directly

7
Planning the Solution
  • Algorithm
  • a logical arithmetical or computational procedure
    that ensures the solution of a problem
  • logic control
  • Plan the algorithm
  • Flowchart a pictorial representation of the
    algorithm

8
Coding the Program
  • Translating the algorithm from the planning stage
    into a programming language
  • All languages have syntax rules
  • Similar to grammatical rules
  • The computer will reject a program with even a
    minor syntax error
  • Programs can be keyed into the computer by using
    a text editor

9
Compiling, Debugging and Testing the Program
  • Compiler translates the program (source module)
    into a machine language version (object module)
  • detects syntax errors
  • object module will be linked to create a .exe
    file (load module)
  • Debugging and Testing Detects logical errors

10
Documenting the Program
  • Materials are generated at each part of the
    process
  • Common examples of documentation
  • Flowchart and/or pseudocode
  • Comments within the source code
  • Testing procedures
  • Layouts of input and output records
  • A narrative description of the program

11
Levels of Languages
  • Lower-level languages more like the 0s and 1s
    the computer itself uses
  • Higher-level languages more like the languages
    people use
  • Divided into five generations
  • Machine language
  • Assembly languages
  • High-level languages
  • Very high-level languages
  • Natural languages

12
Machine Language
  • Programs and memory locations are written in
    strings of 0s and 1s
  • Problems with machine languages
  • Programs are difficult to write and debug
  • Each computer has its own machine language
  • Only option available to early programmers

13
Assembly Languages
  • Substitute mnemonic codes for 0s and 1s
  • For example, Add for add, Comp for compare, etc.
  • Use names rather than binary addresses for memory
    locations
  • Require an assembler to translate the program
    into machine language
  • Still used for programming chips and writing
    utility programs

14
High-Level Languages
  • Transformed programming
  • Programmers could focus on problem solving
    problems rather than manipulating hardware
  • Programs could be written and debugged much more
    quickly
  • Requires a compiler to convert the statements
    into machine language
  • Each computer has its own version of a compiler
    for each language

15
Very High-Level Languages
  • Also called fourth-generation languages (4GLs)
  • Considered nonprocedural languages
  • The programmer specifies the desired results, and
    the language develops the solution
  • Programmers can be about 10 times more productive
    using a fourth-generation language than a
    third-generation language

16
Natural Languages
  • Resemble written or spoken English
  • Programs can be written in a natural syntax,
    rather than in the syntax rules of a programming
    language
  • The language translates the instructions into
    code the computer can execute

17
Major Programming Languages
  • FORTRAN
  • COBOL
  • BASIC
  • Visual Basic
  • C / C
  • Java

18
FORTRAN
  • The first high-level language
  • Stands for FORmula TRANslator
  • Used primarily for engineering, mathematical, and
    scientific tasks

19
COBOL
  • Stands for COmmon Business-Oriented Language
  • Used primarily for business requirements
  • Processes large data files
  • Produces well-formatted reports

20
BASIC
  • Stands for Beginners All-Purpose Symbolic
    Instruction Code
  • Developed to teach programming to college
    students
  • Became very popular with the introduction of the
    microcomputer

21
Visual Basic
  • Allows programmer to create Windows-like user
    interfaces
  • Programmer drags a control (button, text box,
    etc.) onto the form
  • VB creates the code associated with that control
  • VB is event-driven
  • The user controls the program

22
C / C
  • Originally designed to write systems software
  • Offers the ease of use of a high-level language
    with the efficiency of an assembly language
  • Very portable can be used with virtually every
    combination of computer and operating system

23
Java
  • A network-friendly programming language that
    permits a piece of software to run directly on
    many different platforms
  • Allows programmers to write one version of the
    program, rather than a separate version of each
    platform
  • Very useful for Internet development
  • Java applets can run in the users Web browser

24
Object-Oriented Programming
  • Object a self-contained unit that contains both
    data and its related functions
  • Key terms in object-oriented programming
  • Encapsulation an object isolates both its data
    and its related instructions
  • Attributes facts that describe the object
  • Also called properties
  • Methods instructions that tell the object to do
    something
  • Messages an outside stimulus that results in
    the change of the state of an object

25
Using Objects
  • Programmers define classes of objects
  • The class contains all attributes that are unique
    to objects of that class
  • An object is an instance (occurrence) of a class
  • Objects are arranged hierarchically in classes
    and subclasses
  • Subclasses are derived from classes
  • Inheritance a subclass possesses all attributes
    of the class from which it is derived
  • Additional attributes can be coded in the
    subclasses

26
Activating the Object
  • A message is sent to the object, telling it to do
    something
  • The objects methods tell it how to do it
  • Polymorphism each object has its own way to
    process the message
  • For example, the class may have a Move method,
    but each subclass implements that method
    differently

27
Object-Oriented Languages
  • Java
  • C
  • Visual Basic

28
Java
  • A pure object-oriented program
  • Used to create small programs called applets
  • Applets can be delivered over the Web and run on
    any platform

29
C
  • An enhancement of the C language
  • Includes all features of C
  • Adds support for object-oriented programming
  • Can be used as simply an improvement of C,
    without the object-oriented features

30
Visual Basic
  • Previous versions supported some object
    technology
  • The current version, VB.NET, is the first to
    support inheritance and polymorphism
  • These two traits are required for a true
    object-oriented language
Write a Comment
User Comments (0)
About PowerShow.com