c hapter 11

30
Computer Programming CHAPTER 11

Upload: marsden-duffy

Post on 31-Dec-2015

35 views

Category:

Documents


0 download

DESCRIPTION

C HAPTER 11. Computer Programming. Movie Trivia. In what movie did Peter Gibbons file his TPS report with fish guts? Quality Assurance Test Procedure Specification Test Program Set. Computer Programming and Software Engineering. - PowerPoint PPT Presentation

TRANSCRIPT

Computer Programming

CHAPTER 11

Chapter 11: Computer Programming 2

11 Movie Trivia

In what movie did Peter Gibbons file his TPS report with fish guts?

Quality Assurance– Test Procedure Specification– Test Program Set

Chapter 11: Computer Programming 3

11 Computer Programming and Software Engineering

The instructions that make up a computer program are sometimes referred to as code

Programs can have several hundred to 50 million of lines of code

Chapter 11: Computer Programming 4

11 Programming Languages

Programming languages are made up of keywords and grammar rules designed for creating computer instructions

Low-level languages typically include commands specific to a particular CPU or microprocessor family

High-level languages use command words and grammar based on human languages

Chapter 11: Computer Programming 5

11 Programming Languages

First-generation languages– Machine language

Second-generation languages– Assembly language

Third-generation languages– Easy-to-remember command words

Chapter 11: Computer Programming 6

11 Programming Languages

Fourth-generation languages– More closely resembles human language

Fifth-generation languages– Visual GUI

Chapter 11: Computer Programming 7

11 Programming Languages and Paradigms

Chapter 11: Computer Programming 8

11 Program Planning

The problem statement defines certain elements that must be manipulated to achieve a result or goal

You accept assumptions as true to proceed with program planning

Known information helps the computer to solve a problem

Variables vs. constants

Chapter 11: Computer Programming 9

11 Program Coding

Chapter 11: Computer Programming 10

11 Program Coding

A program editor is a type of text editor specially designed for entering code for computer programs

Chapter 11: Computer Programming 11

11 Program Coding

A VDE (visual development environment) provides programmers with tools to build substantial sections of a program– Form design grid– Control– Properties– Event– Event-handling

code

Chapter 11: Computer Programming 12

11 Program Coding

Chapter 11: Computer Programming 13

11 Program Testing and Documentation

A computer program must be tested to ensure that it works correctly

Program errors include– Syntax errors- grammar– Runtime errors- can’t execute– Logic errors- wrong formula or calculation

A debugger can help a programmer read through lines of code and solve problems

Chapter 11: Computer Programming 14

11 Program Testing and Documentation

Remarks or “comments” are a form of documentation that programmers insert into the program code

Chapter 11: Computer Programming 15

11 Algorithms

Set of steps for carrying out a task that can be written down and implemented

Start by recording the steps you take to solve the problem manually– Research and gather information

Specify how to manipulate information Specify what the algorithm should display as

a solution

Chapter 11: Computer Programming 16

11 Expressing an Algorithm

Structured English– Concise English

Pseudocode– Concise English– Algorithm notation

Chapter 11: Computer Programming 17

11 Expressing an Algorithm

Flowchart– Page 621

Chapter 11: Computer Programming 18

11 Expressing an Algorithm

Perform a walkthrough to make sure your algorithm works– Test the code – Use sample data

Chapter 11: Computer Programming 19

11 Sequence, Selection, and Repetition Controls

Sequence control structure- changes orderNormally the program will run in sequential order; 1st, 2nd,3rd,4th,5th

Executing a GOTO commanddirects the computer to a differentpart of the program.

Chapter 11: Computer Programming 20

11 Sequence, Selection, and Repetition Controls

Subroutines, procedures, and functions are sections of code that are part of the program, but not included in the main execution path

Chapter 11: Computer Programming 21

11 Sequence, Selection, and Repetition Controls

Selection control structure

The computer executes a decisionindicated on the flowchart by the question in the diamond shape.

Chapter 11: Computer Programming 22

11 Sequence, Selection, and Repetition Controls

Repetition control structure

To execute a loop, the computerrepeats one or more commands until some condition indicates that the looping should stop.

Chapter 11: Computer Programming 23

11 Procedural Languages Popular procedural languages include FORTRAN,

COBOL, Pascal, C, and BASIC The procedural approach is best used for problems

that can be solved by following a step-by-step algorithm

Calculation efficiency Produces programs that run quickly and efficiently

– Missile guidance • Variables – wind speed, distance, wind direction, target speed,

target heading, launch heading• Constants – fuel, weight, gravity

– Cash registers

Chapter 11: Computer Programming 24

11 Object-Oriented Programming

An object represents an abstract or real-world entity

A class is a template for a group of objects with similar characteristics– A class attribute defines the characteristics of a

set of objects

Chapter 11: Computer Programming 25

11

Chapter 11: Computer Programming 26

11 Object-Oriented Languages

SIMULA was believed to be the first object-oriented computer language

Popular object-oriented languages today are C, C++, Visual Basic, and C#

Chapter 11: Computer Programming 27

11 The Declarative Paradigm

Attempts to describe a problem without specifying exactly how to arrive at a solution– A fact is a statement for solving a problem– Rules describe the relationship between facts– Used for processing words and language

Chapter 11: Computer Programming 28

11 The Declarative Paradigm

A decision table is a tabular method for visualizing and specifying rules based on multiple factors– Price, Delivery, Speed

Chapter 11: Computer Programming 29

11 Declarative Languages

Declarative programming languages are most suitable for problems that pertain to words and concepts rather than to numbers– High effective programming environment– Not commonly used for production applications– Minimal input and output capabilities– Poor performance on today’s personal computer

architecture

Chapter 11: Computer Programming 30

11 Lab Assignment

Create two flowcharts using MS Word– Create a “help” algorithm solution flowchart for a

printer not working– Create a algorithm flowchart that continuously

monitors battery power and will trigger an alarm when the battery is in use and will then shut down the computer if the battery is low on power.

Page 621 has an symbol key