chapter 12
DESCRIPTION
Chapter 12. Computer Programming. Chapter Contents. Section A: Programming Basics Section B: Procedural Programming Section C: Object-Oriented Programming Section D: Declarative Programming Section E: Secure Programming. Programming Basics. Computer Programming and Software Engineering - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/1.jpg)
Computer ProgrammingComputer Programming
Chapter 12Chapter 12
![Page 2: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/2.jpg)
Chapter 12: Computer Programming 2
12 Chapter Contents Section A: Programming Basics Section B: Procedural Programming Section C: Object-Oriented Programming Section D: Declarative Programming Section E: Secure Programming
![Page 3: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/3.jpg)
Chapter 12: Computer Programming 3
12 SECTION AProgramming BasicsProgramming Basics
Computer Programming and Software Engineering
Programming Languages and Paradigms Program Planning Program Coding Program Testing and Documentation Programming Tools
![Page 4: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/4.jpg)
Chapter 12: Computer Programming 4
12 Computer Programming and Software Engineering
The instructions that make up a computer program are commonly referred to as codecode
Programs can have millions of lines of code– Developed by computer programmers (or
software engineers)… programming– Typically stored as a file until it is needed
• Compile• Execute
SourceSource code vs. executableexecutable code
![Page 5: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/5.jpg)
Chapter 12: Computer Programming 5
12 Computer Programming and Software Engineering
![Page 6: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/6.jpg)
Chapter 12: Computer Programming 6
12 Programming Languages and Paradigms
Programming languages are made up of keywordskeywords and grammar rulesgrammar rules designed for creating computer instructions– Keywords can be combined with parameters
Low-level languagesLow-level languages typically include commands specific to a particular CPU or microprocessor family
High-level languagesHigh-level languages use command words and grammar based on human languages
![Page 7: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/7.jpg)
Chapter 12: Computer Programming 7
12 Programming Languages and Paradigms
First-generation languages– Machine language
Second-generation languages– Assembly language
Third-generation languages– Easy-to-remember command words
![Page 8: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/8.jpg)
Chapter 12: Computer Programming 8
12 Programming Languages and Paradigms
Fourth-generation languages– More closely resembles human language
Fifth-generation languages– Based on a declarative programmingdeclarative programming paradigm– Or, use of graphics/visual tools
The programming paradigmparadigm refers to a way of conceptualizing and structuring the tasks a computer performs
![Page 9: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/9.jpg)
Chapter 12: Computer Programming 9
12 Programming Languages and Paradigms
![Page 10: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/10.jpg)
Chapter 12: Computer Programming 10
12 Program Planning The problem statementproblem 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
VariablesVariables vs. constantsconstants Inputs Inputs and Outputs Outputs
![Page 11: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/11.jpg)
Chapter 12: Computer Programming 11
12 Program Planning Problem statement:
Assuming that there are two pizzastwo pizzas to compare, that both pizzas contain the same toppingssame toppings, and that the pizzas could be round or squareround or square, and given the prices, shapes, and sizesprices, shapes, and sizes of the two pizzas, the computer will print a message indicating which pizza has the lower price per which pizza has the lower price per square inchsquare inch
![Page 12: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/12.jpg)
Chapter 12: Computer Programming 12
12 Program Coding
A text editortext editor such asNotepad allows programmersto enter lines of code using a familiar word processing interface.
A program editorprogram editor offers an edit/update environment specific to programming tasks in a given language.
![Page 13: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/13.jpg)
Chapter 12: Computer Programming 13
12 Program Coding A VDE (visual development environmentvisual development environment) provides
programmers with tools to build substantial sections of a program– Form design grid– Control– Properties– Event– Event-Event-
handling handling codecode
Event-driven paradigm
![Page 14: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/14.jpg)
Chapter 12: Computer Programming 14
12 Program Coding
Controls, such as theBest Deal button, can beselected by a programmerfrom a properties list. Here a programmer is selecting the background color for the Best Deal button.
![Page 15: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/15.jpg)
Chapter 12: Computer Programming 15
12 Program Coding
![Page 16: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/16.jpg)
Chapter 12: Computer Programming 16
12 Program Testing and Documentation
A computer program must be tested to ensure that it works correctly
Program errors include– Syntax errorsSyntax errors– Runtime errorsRuntime errors– Logic errorsLogic errors
A debuggerdebugger can help a programmer read through lines of code and solve problems
![Page 17: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/17.jpg)
Chapter 12: Computer Programming 17
12 Program Testing and Documentation
Remarks or “comments” are a form of documentationdocumentation that programmers insert into the program code
![Page 18: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/18.jpg)
Chapter 12: Computer Programming 18
12 Programming Tools An SDK (software development kitsoftware 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 integrated development environmentenvironment) is a type of SDK that packages a set of development tools into a sleek programming application– Program editor, syntax checker, compiler,
debugger, GUI tools, etc.
![Page 19: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/19.jpg)
Chapter 12: Computer Programming 19
12 Programming Tools A componentcomponent is a program module, typically
designed to accomplish a specific task An APIAPI is a set of application program or operating
system functions that programmers can access from within the programs they create– For example, the Windows XP API
C and C++C and C++ are the most popular programming languages– Operating Systems such as Windows, Linux, etc.– Productivity applications– Web server applications– Games
![Page 20: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/20.jpg)
Chapter 12: Computer Programming 20
12 SECTION BProcedural ProgrammingProcedural Programming
Algorithms Expressing an Algorithm Sequence, Selection, and Repetition Controls Procedural Languages and Applications
![Page 21: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/21.jpg)
Chapter 12: Computer Programming 21
12 Algorithms Set of stepssteps 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 data Specify what the algorithm should display/do
as a solution
INPUT PROCESS OUTPUT
![Page 22: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/22.jpg)
Chapter 12: Computer Programming 22
12 Algorithms
![Page 23: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/23.jpg)
Chapter 12: Computer Programming 23
12 Expressing an Algorithm Structured English PseudocodePseudocode
![Page 24: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/24.jpg)
Chapter 12: Computer Programming 24
12 Expressing an Algorithm Flowchart
The pizza program flowchartillustrates how the computershould proceed through theinstructions in the final program.
![Page 25: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/25.jpg)
Chapter 12: Computer Programming 25
12 Expressing an Algorithm Perform a
walkthroughwalkthrough to make sure your algorithm works
![Page 26: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/26.jpg)
Chapter 12: Computer Programming 26
12 Sequence, Selection, and Repetition Controls
Sequence controlSequence control structure
Executing a GOTO commanddirects the computer to a differentpart of the program.
![Page 27: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/27.jpg)
Chapter 12: Computer Programming 27
12 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 main sequential sequential execution pathexecution path
![Page 28: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/28.jpg)
Chapter 12: Computer Programming 28
12 Sequence, Selection, and Repetition Controls
Selection controlSelection control structure
The computer executes a decisionindicated on the flowchart by the question in the diamond shape.
![Page 29: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/29.jpg)
Chapter 12: Computer Programming 29
12 Sequence, Selection, and Repetition Controls
Repetition controlRepetition control structure
To execute a looploop, the computerrepeats one or more commands until some condition indicates that the looping should stop.
![Page 30: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/30.jpg)
Chapter 12: Computer Programming 30
12 Procedural Languages and Applications
Popular procedural languages include FORTRAN, 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 algorithmstep-by-step algorithm– Does not fit well with certain types of problems
Produces programs that run quickly and efficiently
![Page 31: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/31.jpg)
Chapter 12: Computer Programming 31
12 SECTION CObject-Oriented ProgrammingObject-Oriented Programming
Objects and Classes Inheritance Methods and Messages Object-oriented Program Structure Object-oriented Languages and Applications
![Page 32: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/32.jpg)
Chapter 12: Computer Programming 32
12 Objects and Classes An objectobject represents an abstract or real-world
entity A classclass 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
![Page 33: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/33.jpg)
Chapter 12: Computer Programming 38
12 Object-Oriented Languages and Applications
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#C++, Visual Basic, and C#
The OO paradigm results in decreased runtime decreased runtime efficiencyefficiency, but allows encapsulation, which hides the internal details of objects and their methods
![Page 34: Chapter 12](https://reader035.vdocuments.us/reader035/viewer/2022062810/56815c12550346895dc9ef63/html5/thumbnails/34.jpg)
Chapter 12 CompleteChapter 12 Complete
Computer ProgrammingComputer Programming