Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 12 Computer Programming. Chapter Contents Chapter 12: Computer Programming 2  Section A: Programming Basics  Section B: Procedural Programming.

Similar presentations


Presentation on theme: "Chapter 12 Computer Programming. Chapter Contents Chapter 12: Computer Programming 2  Section A: Programming Basics  Section B: Procedural Programming."— Presentation transcript:

1 Chapter 12 Computer Programming

2 Chapter Contents Chapter 12: Computer Programming 2  Section A: Programming Basics  Section B: Procedural Programming  Section C: Object-Oriented Programming  Section D: Declarative Programming  Section E: Secure Programming

3 Programming Basics Chapter 12: Computer Programming 3  Computer Programming and Software Engineering  Programming Languages and Paradigms  Program Planning  Program Coding  Program Testing and Documentation  Programming Tools

4 Computer Programming and Software Engineering Chapter 12: Computer Programming 4  The instructions that make up a computer program are sometimes referred to as code  Programs can have millions of lines of code  Developed by computer programmers  Computer programming

5 Computer Programming and Software Engineering Chapter 12: Computer Programming 5

6 Programming Languages and Paradigms Chapter 12: Computer Programming 6  Programming languages are made up of keywords and grammar rules designed for creating computer instructions  Keywords can be combined with specific parameters  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

7 Programming Languages and Paradigms Chapter 12: Computer Programming 7  First-generation languages  Machine language  Second-generation languages  Assembly language  Third-generation languages  Easy-to-remember command words  Fourth-generation languages  More closely resembles human language  Fifth-generation languages  Based on a declarative programming paradigm The programming paradigm refers to a way of conceptualizing and structuring the tasks a computer performs

8 The evolution of programming paradigms 0-8 * different ways of thinking about communicating with the machine

9 Programming Languages and Paradigms Chapter 12: Computer Programming 9

10 Program Planning Chapter 12: Computer Programming 10  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

11 Program Planning Chapter 12: Computer Programming 11  Exercise in Logic: 1. Write the steps to walk into class and sit down in the first chair at the first table. 2. Write the program prints the phrase "Hello World" infinitely. Things to explain: a. Line numbers b. INPUT c. PRINT d. RUN Source Code 10 PRINT "Hello World!" 20 GOTO 10 Sample Run Hello World! Hello World! etc., etc....

12 Program Coding Chapter 12: Computer Programming 12  A VDE (visual development environment) provides programmers with tools to build substantial sections of a program in a graphical user interface (GUI) format  Form design grid  Control  Properties  Event  Event- handling code

13 Program Testing and Documentation Chapter 12: Computer Programming 13  A computer program must be tested to ensure that it works correctly  Program errors include:  Syntax errors  Runtime errors  Logic errors  A debugger can help a programmer read through lines of code and solve problems

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

15 Programming Tools Chapter 12: Computer Programming 15  An SDK (software development kit) is a collection of language-specific programming tools that enables a programmer to develop applications for a specific computer platform  An IDE (integrated development environment) packages a set of development tools into a sleek programming application. The IDE provides tools for a programmer to make use of multiple SDKs.

16 Programming Tools Chapter 12: Computer Programming 16  A component is a prewritten module, typically designed to accomplish a specific task  An API is a set of application program or operating system functions that programmers can access from within the programs they create  C, Java, and C++ are the most popular programming languages  Particle renderers  Pathfinder algorithms

17 Procedural Programming Chapter 12: Computer Programming 17  Algorithms  Expressing an Algorithm  Sequence, Selection, and Repetition Controls  Procedural Languages and Applications

18 Algorithms Chapter 12: Computer Programming 18  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  Specify how to manipulate information  Specify what the algorithm should display as a solution

19 Example Chapter 12: Computer Programming 19  Using BASIC to add, subtract, multiply and divide: Source Code 10 INPUT "ENTER TWO NUMBERS SEPARATED BY A COMMA: 20 LET S = N1 + N2 30 LET D = N1 - N2 40 LET P = N1 * N2 50 LET Q = N1 / N2 60 PRINT "THE SUM IS ", S 70 PRINT "THE DIFFERENCE IS ", D 80 PRINT "THE PRODUCT IS ", P 90 PRINT "THE QUOTIENT IS ", Q 100 END Sample Run ENTER TWO NUMBERS SEPARATED BY A COMMA: 4, 2 THE SUM IS 6 THE DIFFERENCE IS 2 THE PRODUCT IS 8 THE QUOTIENT IS 2

20 Expressing an Algorithm Chapter 12: Computer Programming 20  Structured English  Pseudocode

21 Expressing an Algorithm Chapter 12: Computer Programming 21  Perform a walkthrough to make sure your algorithm works

22 Sequence, Selection, and Repetition Controls Chapter 12: Computer Programming 22  Sequence control structure Executing a GOTO command directs the computer to a different part of the program.

23 Sequence, Selection, and Repetition Controls Chapter 12: Computer Programming 23  Selection control structure The computer executes a decision indicated on the flowchart by the question in the diamond shape.

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

25 Procedural Languages and Applications Chapter 12: Computer Programming 25  Popular procedural languages include COBOL, FORTH, APL, ALGOL, PL/1, Pascal, C, Ada, and BASIC  The procedural approach is best used for problems that can be solved by following a step- by-step algorithm  Does not fit gracefully with certain types of problems  Produces programs that run quickly and use system resources efficiently

26 Object-Oriented Programming Chapter 12: Computer Programming 26  Objects and Classes  Inheritance  Methods and Messages  Object-oriented Program Structure  Object-oriented Languages and Applications

27 Objects and Classes Chapter 12: Computer Programming 27  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  Public vs. private attributes

28 Inheritance Chapter 12: Computer Programming 28  Passing certain characteristics from one class to other classes  Superclass  Subclass  Class hierarchy

29 Methods and Messages Chapter 12: Computer Programming 29  A method is a segment of code that defines an action  Collect input, perform calculations, etc.  A method is activated by a message  Can be defined along with the class they affect  Polymorphism refers to the ability to redefine a method in a subclass  Helps simplify program code

30 Object-Oriented Program Structure Chapter 12: Computer Programming 30

31 Object-Oriented Program Structure Chapter 12: Computer Programming 31

32 Object-Oriented Program Structure Chapter 12: Computer Programming 32 When the pizza program runs, on-screen prompts ask for the shape, size, and price of each pizza; then the program displays a message that indicates which pizza is the best deal.

33 Object-Oriented Languages and Applications Chapter 12: Computer Programming 33  SIMULA was believed to be the first object-oriented computer language  The Dynabook project was the second major development in object-oriented languages  Popular object-oriented languages today are Ada95, C++, Visual Basic, and C#  Facets of the object-oriented paradigm can also increase a programmer’s efficiency because encapsulation allows objects to be adapted and reused in a variety of different programs

34 Declarative Programming Chapter 12: Computer Programming 34  The Declarative Paradigm  Prolog Facts  Prolog Rules  Input Capabilities  Declarative Languages and Applications

35 The Declarative Paradigm Chapter 12: Computer Programming 35  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

36 The Declarative Paradigm Chapter 12: Computer Programming 36  A decision table is a tabular method for visualizing and specifying rules based on multiple factors

37 Declarative Languages and Applications Chapter 12: Computer Programming 37  Declarative programming languages are most suitable for problems that pertain to words and concepts rather than to numbers  Highly effective programming environment  Not commonly used for production applications  Minimal input and output capabilities  Poor performance on today’s personal computer architecture


Download ppt "Chapter 12 Computer Programming. Chapter Contents Chapter 12: Computer Programming 2  Section A: Programming Basics  Section B: Procedural Programming."

Similar presentations


Ads by Google