300 likes | 387 Views
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.
E N D
CHAPTER 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 Chapter 11: Computer Programming
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
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
Programming Languages • First-generation languages • Machine language • Second-generation languages • Assembly language • Third-generation languages • Easy-to-remember command words Chapter 11: Computer Programming
Programming Languages • Fourth-generation languages • More closely resembles human language • Fifth-generation languages • Visual GUI Chapter 11: Computer Programming
Programming Languages and Paradigms Chapter 11: Computer Programming
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
Program Coding Chapter 11: Computer Programming
Program Coding • A program editor is a type of text editor specially designed for entering code for computer programs Chapter 11: Computer Programming
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
Program Coding Chapter 11: Computer Programming
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
Program Testing and Documentation • Remarks or “comments” are a form of documentation that programmers insert into the program code Chapter 11: Computer Programming
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
Expressing an Algorithm • Structured English • Concise English • Pseudocode • Concise English • Algorithm notation Chapter 11: Computer Programming
Expressing an Algorithm • Flowchart • Page 621 Chapter 11: Computer Programming
Expressing an Algorithm • Perform a walkthrough to make sure your algorithm works • Test the code • Use sample data Chapter 11: Computer Programming
Sequence, Selection, and Repetition Controls • Sequence control structure- changes order Normally the program will run in sequential order; 1st, 2nd,3rd,4th,5th Executing a GOTO command directs the computer to a different part of the program. Chapter 11: Computer Programming
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
Sequence, Selection, and Repetition Controls • Selection control structure The computer executes a decision indicated on the flowchart by the question in the diamond shape. Chapter 11: Computer Programming
Sequence, Selection, and Repetition Controls • 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
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
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
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
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
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
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
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 Chapter 11: Computer Programming