CHAPTER 11 Computer Programming 1 Movie Trivia 1In

  • Slides: 30
Download presentation
CHAPTER 11 Computer Programming

CHAPTER 11 Computer Programming

1 Movie Trivia 1ïIn what movie did Peter Gibbons file his TPS report with

1 Movie Trivia 1ï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 2

1 Computer Programming and Software Engineering 1ïThe instructions that make up a computer program

1 Computer Programming and Software Engineering 1ï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 3

1 Programming Languages 1ïProgramming languages are made up of keywords and grammar rules designed

1 Programming Languages 1ï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 4

1 Programming Languages 1ïFirst-generation languages – Machine language ïSecond-generation languages – Assembly language ïThird-generation

1 Programming Languages 1ïFirst-generation languages – Machine language ïSecond-generation languages – Assembly language ïThird-generation languages – Easy-to-remember command words Chapter 11: Computer Programming 5

1 Programming Languages 1ïFourth-generation languages – More closely resembles human language ïFifth-generation languages –

1 Programming Languages 1ïFourth-generation languages – More closely resembles human language ïFifth-generation languages – Visual GUI Chapter 11: Computer Programming 6

1 Programming Languages and Paradigms 1 Chapter 11: Computer Programming 7

1 Programming Languages and Paradigms 1 Chapter 11: Computer Programming 7

1 Program Planning 1ïThe problem statement defines certain elements that must be manipulated to

1 Program Planning 1ï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 8

1 Program Coding 1 Chapter 11: Computer Programming 9

1 Program Coding 1 Chapter 11: Computer Programming 9

1 Program Coding 1ïA program editor is a type of text editor specially designed

1 Program Coding 1ïA program editor is a type of text editor specially designed for entering code for computer programs Chapter 11: Computer Programming 10

1 Program Coding 1ïA VDE (visual development environment) provides programmers with tools to build

1 Program Coding 1ïA VDE (visual development environment) provides programmers with tools to build substantial sections of a program – Form design grid – Control – Properties – Event-handling code Chapter 11: Computer Programming 11

1 Program Coding 1 Chapter 11: Computer Programming 12

1 Program Coding 1 Chapter 11: Computer Programming 12

Program Testing and 1 Documentation 1 ïA computer program must be tested to ensure

Program Testing and 1 Documentation 1 ï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 13

Program Testing and 1 Documentation 1 ïRemarks or “comments” are a form of documentation

Program Testing and 1 Documentation 1 ïRemarks or “comments” are a form of documentation that programmers insert into the program code Chapter 11: Computer Programming 14

1 Algorithms 1ïSet of steps for carrying out a task that can be written

1 Algorithms 1ï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 15

1 Expressing an Algorithm 1ïStructured English – Concise English ïPseudocode – Concise English –

1 Expressing an Algorithm 1ïStructured English – Concise English ïPseudocode – Concise English – Algorithm notation Chapter 11: Computer Programming 16

1 Expressing an Algorithm 1ïFlowchart – Page 621 Chapter 11: Computer Programming 17

1 Expressing an Algorithm 1ïFlowchart – Page 621 Chapter 11: Computer Programming 17

1 Expressing an Algorithm 1ïPerform a walkthrough to make sure your algorithm works –

1 Expressing an Algorithm 1ïPerform a walkthrough to make sure your algorithm works – Test the code – Use sample data Chapter 11: Computer Programming 18

1 Sequence, Selection, and Repetition Controls 1ïSequence control structure- changes order Normally the program

1 Sequence, Selection, and Repetition Controls 1ïSequence control structure- changes order Normally the program will run in sequential order; 1 st, 2 nd, 3 rd, 4 th, 5 th Executing a GOTO command directs the computer to a different part of the program. Chapter 11: Computer Programming 19

1 Sequence, Selection, and Repetition Controls 1ïSubroutines, procedures, and functions are sections of code

1 Sequence, Selection, and Repetition Controls 1ï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 20

1 Sequence, Selection, and Repetition Controls 1ïSelection control structure The computer executes a decision

1 Sequence, Selection, and Repetition Controls 1ïSelection control structure The computer executes a decision indicated on the flowchart by the question in the diamond shape. Chapter 11: Computer Programming 21

1 Sequence, Selection, and Repetition Controls 1ïRepetition control structure To execute a loop, the

1 Sequence, Selection, and Repetition Controls 1ïRepetition control structure To execute a loop, the computer repeats one or more commands until some condition indicates that the looping should stop. Chapter 11: Computer Programming 22

1 Procedural Languages 1ï Popular procedural languages include FORTRAN, COBOL, Pascal, C, and BASIC

1 Procedural Languages 1ï 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 23

1 Object-Oriented Programming 1ïAn object represents an abstract or real-world entity ïA class is

1 Object-Oriented Programming 1ï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 24

1 1 Chapter 11: Computer Programming 25

1 1 Chapter 11: Computer Programming 25

1 Object-Oriented Languages 1ïSIMULA was believed to be the first objectoriented computer language ïPopular

1 Object-Oriented Languages 1ïSIMULA was believed to be the first objectoriented computer language ïPopular object-oriented languages today are C, C++, Visual Basic, and C# Chapter 11: Computer Programming 26

1 The Declarative Paradigm 1ïAttempts to describe a problem without specifying exactly how to

1 The Declarative Paradigm 1ï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 27

1 The Declarative Paradigm 1ïA decision table is a tabular method for visualizing and

1 The Declarative Paradigm 1ïA decision table is a tabular method for visualizing and specifying rules based on multiple factors – Price, Delivery, Speed Chapter 11: Computer Programming 28

1 Declarative Languages 1ïDeclarative programming languages are most suitable for problems that pertain to

1 Declarative Languages 1ï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 29

1 Lab Assignment 1ïCreate two flowcharts using MS Word – Create a “help” algorithm

1 Lab Assignment 1ï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 Chapter 11: Computer Programming 30