22
New Perspectives on Computer Concepts (11 th Edition) Instructor’s Manual1 of 22 Computer Concepts Chapter Twelve: Computer Programming A Guide to this Instructor’s Manual: We have designed this Instructor’s Manual to supplement and enhance your teaching experience through classroom activities and a cohesive chapter summary. This document is organized chronologically, using the same heading in blue that you see in the textbook. Under each heading you will find (in order): Lecture Notes that summarize the section, Figures and Boxes found in the section (if any), Teacher Tips, Classroom Activities, and Lab Activities. Pay special attention to teaching tips, and activities geared towards quizzing your students, enhancing their critical thinking skills, and encouraging experimentation within the software. In addition to this Instructor’s Manual, our Instructor’s Resources CD also contains PowerPoint Presentations, Test Banks, and other supplements to aid in your teaching experience. For your students: Our latest online feature, CourseCasts, is a library of weekly podcasts designed to keep your students up to date with the latest in technology news. Direct your students to http://coursecasts.course.com , where they can download the most recent CourseCast onto their mp3 player. Ken Baldauf, host of CourseCasts, is a faculty member of the Florida State University Computer Science Department where he is responsible for teaching technology classes to thousands of FSU students each year. Ken is an expert in the latest technology and sorts through and aggregates the most pertinent news and information for CourseCasts so your students can spend their time enjoying technology, rather than trying to figure it out. Open or close your lecture with a discussion based on the latest CourseCast. Table of Contents Chapter Objectives 2 Section A: Programming Basics 2 Section B: Procedural Programming 6

Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

New Perspectives on Computer Concepts (11th Edition) Instructor’s Manual 1 of 17

Computer ConceptsChapter Twelve: Computer Programming

A Guide to this Instructor’s Manual:We have designed this Instructor’s Manual to supplement and enhance your teaching experience through classroom activities and a cohesive chapter summary. This document is organized chronologically, using the same heading in blue that you see in the textbook. Under each heading you will find (in order): Lecture Notes that summarize the section, Figures and Boxes found in the section (if any), Teacher Tips, Classroom Activities, and Lab Activities. Pay special attention to teaching tips, and activities geared towards quizzing your students, enhancing their critical thinking skills, and encouraging experimentation within the software. In addition to this Instructor’s Manual, our Instructor’s Resources CD also contains PowerPoint Presentations, Test Banks, and other supplements to aid in your teaching experience.

For your students: Our latest online feature, CourseCasts, is a library of weekly podcasts designed to keep your students up to date with the latest in technology news. Direct your students to http://coursecasts.course.com, where they can download the most recent CourseCast onto their mp3 player. Ken Baldauf, host of CourseCasts, is a faculty member of the Florida State University Computer Science Department where he is responsible for teaching technology classes to thousands of FSU students each year. Ken is an expert in the latest technology and sorts through and aggregates the most pertinent news and information for CourseCasts so your students can spend their time enjoying technology, rather than trying to figure it out. Open or close your lecture with a discussion based on the latest CourseCast.

Table of Contents Chapter Objectives 2Section A: Programming Basics 2Section B: Procedural Programming 6Section C: Object-Oriented Programming 9Section D: Declarative Programming 12Section E: Secure Programming 14Glossary of Key Terms 16

Page 2: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

New Perspectives on Computer Concepts (11th Edition) Instructor’s Manual 2 of 17

Chapter Objectives Students will have mastered the material in Chapter Twelve when they can:

Describe the roles of computer programmers and software engineers

Categorize today’s popular computer programming languages by generation and paradigm

Explain the process of planning, coding, and testing a computer program

Describe the advantages and disadvantages of generic text editors, program editors, and VDEs for coding computer programs

Define the term algorithm and describe how it relates to procedural programming

Identify various tools that programmers use to plan programs, such as flowcharts, structured English, pseudocode, UML diagrams, and decision tables

Follow the control structures for a procedural program

Describe the major concepts of object-oriented programming, such as objects, classes, inheritance, messages, methods, polymorphism, and encapsulation

Create some basic facts and rules using Prolog syntax

Describe how a declarative language, such as Prolog, satisfies goals by instantiation

Describe vulnerabilities in software program code and explain the steps programmers can take to write more secure code

List steps that consumers can take to avoid vulnerabilities that exist in software with code defects

Page 3: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

SECTION A: PROGRAMMING BASICS (674)

Computer Programming and Software Engineering (674)LECTURE NOTES

Distinguish between the responsibilities of a systems analyst and a software engineer.

Emphasize the importance of planning. Explain that programmers usually follow a structured software engineering

methodology when they write programs. Emphasize that programmers must plan their programs before they start writing to

save significant time and trouble later on.

TEACHER TIPYou might tie this discussion to Chapter 9, when you discussed the computer marketplace and computer careers.

FIGURES Figure 12-1, Figure 12-2

Page 4: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

CLASSROOM ACTIVITIES1. Assign a Project: Have students write a paragraph comparing and contrasting

computer programming and software engineering.2. Quick Quiz:

The instructions that make up a computer program are sometimes referred to as _______. (Answer: code.)

True/False: Computer programmers typically focus on coding computer programs, whereas software engineers tend to focus on designing and testing activities. (Answer: True.)

Computer programming includes which of the following activities?a. planningb. coding

c. testingd. All of the above

(Answer: D.)

Programming Languages and Paradigms (676) LECTURE NOTES

Compare programming languages. Review what a programming language is and how languages are categorized. Spend some time discussing the history of computer languages, explaining about

the different generations of languages. Explain that programming paradigms refer to a way of conceptualizing and

structuring the tasks that a computer performs. Refer to Figure 12-8 to differentiate between the various programming paradigms

and their descriptions.

FIGURES Figure 12-3, Figure 12-4, Figure 12-5, Figure 12-6, Figure 12-7, Figure 12-8

CLASSROOM ACTIVITIES1. Class Discussion: Ask students if they are familiar with any programming

languages. Which one(s) and to what degree? Refer to the tables in Figures 12-7 and 12-8 for some examples of programming languages.

2. Quick Quiz: A(n) _______, or command, is a word with a predefined meaning for the compiler

or interpreter that translates each line of program code into machine language. (Answer: keyword.)

True/False: A low-level language uses command words and grammar based on human languages. (Answer: False.)

Prolog is an example of which generation of programming languages?a. firstb. third

c. fourthd. fifth

(Answer: D.)

Program Planning (680)LECTURE NOTES

Discuss the problem statement. Students need to be able to read a problem statement and understand the

problem before beginning the project. Distinguish variables and constants. Review the methodologies listed on page 681.

TEACHER TIP

Page 5: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

Many students who have trouble with computer programming seem to be too impatient to arrive at a solution. For these students it is particularly important to stress that it is worthwhile to spend time crafting a good problem statement. You can follow a cookbook approach for a problem statement: state the assumptions, specify known information (givens), perform calculations, and specify output. A rule of thumb is to spend 80% of your time thinking about the problem and algorithm, and 20% of your time writing the code.

FIGURES Figure 12-9, Figure 12-10

CLASSROOM ACTIVITIES1. Assign a Project: Have students list the characteristics of a good problem

statement.2. Quick Quiz:

A(n) ___________ represents a value that can change. (Answer: variable.) True/False: The known information in a problem statement is the information

that you supply to the computer to help it solve a problem. (Answer: True.) What type of methodology requires extensive planning and documentation up

front?a. predictiveb. agile

c. Both A and Bd. Neither A nor B

(Answer: A.)

Program Coding (682)LECTURE NOTES

Explain that some languages come with coding windows to enter the program statements.

Explain that the VDE (visual development environment) provides programmers with tools to build substantial sections of a program by pointing and clicking, rather than typing lines of code.

In Figure 12-12 and Figure 12-13, examples of Visual Basic programs show the form design and the controls and properties attached to the form objects.

Discuss other programming languages.

TEACHER TIPIf you are using a programming language other than Visual Basic in this course, it is fairly simple to convert the code for the pizza program into a different language.

FIGURES Figure 12-11, Figure 12-12, Figure 12-13, Figure 12-14

CLASSROOM ACTIVITIES1. Assign a Project: Have students search the Internet for program editors. How many

can they find available for purchase and for free?2. Quick Quiz:

A(n) ____________ is a type of text editor specially designed for entering code for computer programs. (Answer: program editor.)

True/False: In a visual development environment, each control comes with a predefined set of events. (Answer: True.)

What does VDE stand for? (Answer: Visual development environment.)

Page 6: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

LAB ACTIVITYThe Course Lab “Using a Visual Development Environment” deals with issues that relate to this section of the textbook. You might want to go through the lab during class time if you have a computer with a projection device. Or, assign this lab for students to do on their own.

LAB ACTIVITYRefer students to the New Perspectives Web site for a Student Edition Lab called “Visual Programming.”

Program Testing and Documentation (685)LECTURE NOTES

Stress the importance of complete program testing and make sure your students understand the idea that testing is not complete until each line of the program has been tested at least once.

Point out that when writing large programs, it is important to test each module by itself, and then test the entire program after the module has been inserted.

Discuss the differences between syntax errors and logic errors, and the potential consequences that could arise from a program that contains errors.

Explain to students that syntax errors are found when compiling the program and logic errors are found during execution of the program.

Review the use of compilers and interpreters in running programs. Mention that some programming languages compile and run with one command, like Visual Basic, whereas C++ requires a compile and then an execution command.

Introduce debugging and explain that programmers can locate errors in a program by reading through lines of code, or then can use a tool called a debugger that allows programmers to step through a program and monitor the status of variables, input, and output.

Explain that program documentation may take several forms, including remarks embedded in the program code, program manuals, and user references.

Identify the program remarks included in a sample source listing, such as Figure 12-16, which contains a BASIC listing of the pizza program.

Students should be able to distinguish between program documentation and user documentation, which is often written by a technical writer.

TEACHER TIPIf possible, bring in samples of program and user documentation for comparison. As an additional project, you might ask students to write the user documentation for the pizza program or for any other sample program.

FIGURES Figure 12-15, Figure 12-16

Programming Tools (686)LECTURE NOTES

Explain that a component is a prewritten module designed to accomplish a specific task.

Explain that an API (application program interface) is a set of application programming or operating system functions that programmers can access within the programs they create.

Page 7: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

Point out that an API provides programmers with a very detailed set of function cells, whereas a component provides less control over details but require less programming.

TEACHER TIPYou might want to discuss that two general categories of policies exist regarding APIs. Some companies guard their APIs carefully. Sony used to make its official PlayStation 2 API available only to licensed PlayStation developers because Sony wanted to restrict how many people could write a PlayStation 2 game, and wanted to profit from them as much as possible. This is typical of companies who do not profit from the sale of API implementations (in this case, Sony broke-even on the sale of PlayStation 2 consoles and even took a loss on marketing, but made it up through game royalties created by API licensing). However, PlayStation 3 is based entirely on open and publicly available APIs. Other companies propagate their APIs freely. For example, Microsoft deliberately makes most of its API information public, so that software will be written for the Windows platform. The sale of the third-party software sells copies of Microsoft Windows. This is typical of companies who profit from the sale of API implementations (in this case, Microsoft Windows, which is sold at a gain for Microsoft).

FIGURES Figure 12-17, Figure 12-18

CLASSROOM ACTIVITIES1. Assign a Project: Have students practice writing problem definition statements and include the diagram of the expected output.2. Quick Quiz:

A(n) _____ is a prewritten module, typically designed to accomplish a specific task. (Answer: component.)

True/False: A software engineer designs, codes, tests, and documents software, but tends to focus on designing and testing activities. (Answer: True.)

An example of a third-generation language is _______.a. Pascalb. Assemblerc. SQLd. Prolog(Answer: A.)

SECTION B: PROCEDURAL PROGRAMMING (689)

Algorithms (689)LECTURE NOTES

Explain that algorithms are a series of steps for carrying out a task that can be written down and implemented.

Use Figure 12-20 to show the steps contained in one of the pizza program algorithms. Compare this to Figure 12-21, which extends these steps and provides more detail.

FIGURES Figure 12-19, Figure 12-20, Figure 12-21

CLASSROOM ACTIVITIES

Page 8: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

1. Group Activity: Divide the class into two groups and have each group write an algorithm for a simple task that can be completed in the classroom. Have the groups exchange algorithms and attempt to carry out each other’s instructions. Were any steps left out? Was each group able to successfully complete the algorithm?

2. Quick Quiz: A(n) _________ is a set of steps for carrying out a task that can be written down

and implemented. (Answer: algorithm.) True/False: The traditional approach to programming uses a procedural

paradigm. (Answer: True.) True/False: Algorithms are usually written in a format that is specific to a

particular programming language. (Answer: False.)

Expressing an Algorithm (692)LECTURE NOTES

Introduce pseudocode using Figure 12-22, which shows the pizza problem algorithm expressed in pseudocode.

Explain that as with structured English, there are variations on the conventions used to write pseudocode, but one standard convention has the following features:

A limited set of non-computer language specific command words are used, e.g., display, input, IF...THEN, output.

The command words are often indicated in bold. An arrow symbol () indicates that the value of a variable changes, e.g.,

SquareInches1 Size1 * Size1. The = symbol is used in logical expressions, e.g., If Shape1 = “round”. The commands associated with an IF...THEN statement or other control

structures are indented. Output messages are surrounded by quotes.

Figure 12-23 shows a flowchart for the pizza program. Review the flowchart symbols before you walk through the program flow.

Figure 12-24 shows how to check the pseudocode for the pizza program.

FIGURES Figure 12-22, Figure 12-23, Figure 12-24

CLASSROOM ACTIVITIES1. Assign a Project: Have students sketch a flowchart for the algorithm they created in

the previous section. Have them make sure to correct any errors that were discovered.

2. Quick Quiz: _________ is a notational system for algorithms that has been described as a

mixture of English and your favorite programming language. (Answer: Pseudocode.)

Before finalizing the algorithm for a computer program, you should perform what? (Answer: A walkthrough.)

True/False: Structured English is a subset of the English language with a vast selection of sentence structures that reflect processing activities. (Answer: False.)

Sequence, Selection, and Repetition Controls (695)LECTURE NOTES

Discuss control structures.

Page 9: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

Compare a sequence control, Figure 12-25, which changes the order of instructions the computer performs, to a selection control (Figure 12-27), which tells the computer what to do based on whether a condition is true or false.

Explain that repetition controls are also called loops or iterations, and repeat one or more instructions until a condition is met. The flowchart in Figure 12-28 demonstrates the looping process.

Discuss which types of controls you might use in the pizza program—sequence, selection, or repetition—and for what purpose. Students may need to use all types within the flowchart or program.

TEACHER TIPStudents might need some help with the sections on control structures, depending on the depth of understanding you wish them to develop. The text is written with the goal that students will be able to list the three types of control structures (sequence, selection, and repetition controls) and describe the purpose of each.

FIGURES Figure 12-25, Figure 12-26, Figure 12-27, Figure 12-28, Figure 12-29

CLASSROOM ACTIVITIES1. Class Discussion: Ask students to explain why experienced programmers prefer

sequence controls to the GOTO command.2. Quick Quiz:

During ____________ the first instruction in the program is executed first, then the second instruction, and so on, to the last instruction in the program. (Answer: sequential execution.)

True/False: Control structures are instructions that specify the sequence in which a program is executed. (Answer: True.)

List at least two of the most frequently used repetition commands. (Answers: FOR…NEXT, DO…WHILE, DO…UNTIL, WHILE…WEND.)

Procedural Languages and Applications (700)LECTURE NOTES

Discuss what makes a program a procedural language. List some of the most popular procedural languages. Review the advantages and disadvantages of the procedural paradigm as

discussed on page 701.

TEACHER TIPThere is a tendency to classify a computer language into a single category— statements such as “COBOL is a procedural language” and “BASIC is an interpreted language” are typical. However, a computer language has many characteristics. For example, BASIC provides high-level commands, is usually interpreted, and is procedural. The approach in Chapter 12 is to apply characteristics to computer languages, rather than to attempt to classify them into a single category. You should reinforce this idea for your students.

CLASSROOM ACTIVITIES1. Assign a Project: Have the students create the pseudocode and flowchart to output the sum of 10 numbers. Students should use sequence and selection structures.2. Quick Quiz:

Page 10: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

A notational system for that has been described as mixture of English and your favorite programming language is known as ________________. (Answer: Pseudocode.)

True/False: A flowchart is a graphical representation of the way that a computer should progress from one instruction to the next when it performs a task. (Answer: True.)

A control structure that is referred to as a decision structure or branch is called _______.a. sequenceb. do…while

c. selectiond. repetition

(Answer: C.)

SECTION C: OBJCET-ORIENTED PROGRAMMING (702)

Objects and Classes (702)LECTURE NOTES

Explain that the object-oriented paradigm is based on the idea that the solution for a problem can be visualized in terms of objects that interact with each other.

Point out that an object is defined as a unit of data that represents an abstract or real-world entity.

Examples of objects are shown in Figure 12-30. Distinguish between an object and a class. There can be many objects but in order

to organize similar objects, a class is created. A class is a template for a group of objects with similar characteristics.

Discuss the data types associated with the class and review the UML (unified modeling language) diagram in Figure 12-32. The class is named, the data types are defined, and the type of attribute is designated.

FIGURES Figure 12-30, Figure 12-31, Figure 12-32

CLASSROOM ACTIVITIES1. Class Discussion: Display the class attribute data types on an overhead monitor or

whiteboard and have students describe each one and provide an example of each one. Refer to Figure 12-31 if necessary.

2. Quick Quiz: A(n) _________ is a unit of data that represents an abstract or real-world entity,

such as a person, place, or thing. (Answer: object.) True/False: The object-oriented paradigm is based on the idea that the solution

for a problem can be visualized in terms of objects that interact with each other. (Answer: True.)

In terms of object-oriented programming, what is a class? (Answer: A template for a group of objects with similar characteristics.)

Inheritance (704)LECTURE NOTES

Explain that in object-oriented terms, inheritance refers to passing certain characteristics from one class to other classes. This process produces new classes with inherited attributes, creating a superclass and subclasses.

Review the hierarchical structure in Figure 12-33.

TEACHER TIP

Page 11: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

Consider using examples other than the pizza program to demonstrate the use of inheritance. For example, if a program needs to compute a shipping cost based on the weight of the items they will need the item and its weight. The weight will be added to other items’ weight producing a total weight. This total weight will then be used in a calculation to determine the shipping cost.

FIGURES Figure 12-33, Figure 12-34

CLASSROOM ACTIVITIES1. Quick Quiz:

____________ refers to passing certain characteristics from one class to other classes. (Answer: Inheritance.)

True/False: A subclass is any class from which attributes can be inherited. (Answer: False.)

True/False: A subclass is any class that inherits attributes from a superclass. (Answer: True.)

What is the set of superclasses and subclasses that are related to each other called?. (Answer: Class hierarchy.)

Methods and Messages (705)LECTURE NOTES

Explain that a method is a segment of code that defines an action. A method can perform a variety of tasks, such as exiting a program, a calculation

or producing output. Point out that methods can be defined along with the class they affect. Review the diagram in Figure 12-37 to identify the use of polymorphism.

TEACHER TIPThis section uses Java programming code as examples. Most students at this level have not had any programming experience so this may be difficult to understand at this time. An example using the terminology in this section would be to use the algorithm approach where the student needs to identify the inputs, processing, and outputs. The processing section is where the methods and polymorphism are best identified.

FIGURES Figure 12-35, Figure 12-36, Figure 12-37, Figure 12-38

CLASSROOM ACTIVITIES1. Assign a Project: Ask students to write a paragraph explaining how methods relate

to classes.2. Quick Quiz:

A(n) __________ is a segment of code that defines an action. (Answer: method.) True/False: A method can perform only one task. (Answer: False.) A method is activated by what? (Answer: A message.)

Object-Oriented Program Structure (709)LECTURE NOTES

Discuss using classes and methods. In Figure 12-39, the structure of the program is given with the definitions, method,

calculations, and outputs. Use Figure 12-40 to identify each part of the program structure using Java code.

Page 12: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

Explain that the final step in the program structure is to run the program and display the output.

FIGURES Figure 12-39, Figure 12-40, Figure 12-41

Object-Oriented Languages and Applications (711)LECTURE NOTES

Discuss the origin of object-oriented languages, including SmallTalk. Discuss some object-oriented languages in use today. These include C++, Visual

Basic, and Java. Point out that advantages of object-oriented languages include an approach that is

cognitively similar to the way humans perceive their world, and encapsulation, which allows objects to be reused in different ways.

CLASSROOM ACTIVITIES1. Class Discussion: Have students review sample Java code, identifying methods and classes.2. Quick Quiz:

A(n) ______ is any class that inherits attributes from a superclass. (Answer: subclass.)

True/False: Polymorphism provides OO programs with easy extensibility and can help simplify program code. (Answer: True.)

A segment of code that defines an action is known as a(n) ______.a. methodb. messagec. subclassd. class(Answer: A.)

Page 13: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

SECTION D: DECLARATIVE PROGRAMMING (713)

The Declarative Paradigm (713)LECTURE NOTES

Explain that unlike procedural languages, which tell the computer how to solve a problem, a declarative language describes the problem.

Point out that declarative languages are useful for programs that manipulate ideas and concepts, rather than numbers.

TEACHER TIPYou might want to return to the types of problems you discussed in Section A. Identify which type of language characteristics—procedural, object-oriented, or declarative—are most appropriate for solving these and other problems.

FIGURES Figure 12-42, Figure 12-43

CLASSROOM ACTIVITIES1. Class Discussion: Ask students to discuss how the procedural, object-oriented, and

declarative paradigms are similar and different. Refer to Figure 12-42 for information about each.

2. Quick Quiz: The ____________ emphasizes the evaluation of expressions, called functions,

rather than the execution of commands. (Answer: functional paradigm.) The _____________ attempts to describe a problem without specifying exactly

how to arrive at a solution. (Answer: declarative paradigm.) True/False: A decision table is a tabular method for visualizing and specifying

rules based on multiple factors. (Answer: True.)

Prolog Facts (714)LECTURE NOTES

Explain that in the context of a Prolog program, a fact is a statement that provides the computer with basic information for solving a problem.

The coding statements syntax is shown in Figure 12-44. Discuss arguments and predicates, and constants and variables, and their

meanings in Prolog.

FIGURES Figure 12-44, Figure 12-45, Figure 12-46, Figure 12-47

Page 14: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

CLASSROOM ACTIVITIES1. Quick Quiz:

A(n) ____________ represents one of the main subjects that a fact describes. (Answer: argument.)

The __________ describes the relationship between the arguments. (Answer: predicate.)

True/False: A Prolog fact follows specific syntax rules. (Answer: True.) Finding a value for a variable is referred to as _________. (Answer: instantiation.) True/False: Prolog is a procedural programming language. (Answer: False.)

Prolog Rules (718)LECTURE NOTES

Explain that a Prolog rule consists of a head, body, and connecting symbols, as shown in Figure 12-49.

The Prolog Fact program uses the facts to make decisions and then produces a solution.

Compare Prolog to other programming languages, such as C++ and Visual Basic by comparing the code.

FIGURES Figure 12-48, Figure 12-49, Figure 12-50

CLASSROOM ACTIVITIES1. Class Discussion: On an overhead projector or whiteboard, display a Prolog rule.

Have students identify the head, the clauses that form the body of the rule, and the connecting symbol.

Input Capabilities (720)LECTURE NOTES

Explain that Prolog, like other languages, allows coding for user input. Use Figure 12-50 to point out the series of prompts that asks the user for the price,

size, and shape of pizza 1 and pizza 2. Explain that this data is then used to produce the price of the pizza.

FIGURES Figure 12-51

Declarative Languages and Applications (722)LECTURE NOTES

Explain that declarative languages are most suitable for problems that pertain to words and concepts rather than numbers.

Examples given are genealogy, or street and highway databases for mapping routes.

Point out that declarative languages give more flexibility in solving problems.

FIGURES Figure 12-52

CLASSROOM ACTIVITIES1. Class Discussion: Have students review a problem statement and list the facts

needed to solve the problem.2. Quick Quiz

Page 15: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

In the context of a Prolog program a(n) ______ is a statement that provides the computer with the basic information for solving a problem. (Answer: fact.)

True/False: An argument represents one of the main subjects that a fact describes. (Answer: True.)

Given the following Prolog fact: sizeof(room,area). Room is an example of a(n) ________.a. variableb. argument

c. end of a factd. beginning of a fact

(Answer: B.)

SECTION E: SECURE PROGRAMMING (723)

Black Hat Exploits (723)LECTURE NOTES

Explain buffer overflow, also called buffer overrun. Discuss the error message in Figure 12-54 and why it is problematic.

TEACHER TIPConsider having students compare their experiences with black-hat exploits. What steps have they taken to prevent them?

FIGURES Figure 12-53, Figure 12-54

CLASSROOM ACTIVITIES1. Class Discussion: Ask students what types of black hat exploits they’ve heard of or

dealt with. Could these have been prevented by better programming?2. Quick Quiz:

A(n) ____________ is a condition in which data in memory exceeds its expected boundaries and flows into memory areas intended for use by other data. (Answer: buffer overflow or buffer overrun.)

What are the two languages most commonly used for professional software development? (Answers: C, C++.)

True/False: Today’s operating systems, utilities, and application software are impervious to black-hat exploits. (Answer: False.)

Secure Software Development (725)LECTURE NOTES

Explain that a threat model defines a set of possible attacks to consider. Point out that a threat model allows you to assess the probability, the potential

harm, the priority, etc. of attacks, and from this point on try to minimize or eradicate the threats.

Use Figure 12-56 to explain what an attack tree is.

TEACHER TIPFigure 12-57 shows a digital certificate. Ask students if they’re encountered certificates like the one shown. If possible, demonstrate one to the class.FIGURES

Figure 12-55, Figure 12-56, Figure 12-57

CLASSROOM ACTIVITIES

Page 16: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

1. Assign a Project: Ask students to sketch an attack tree illustrating a potential attack intended to steal students’ passwords.

2. Quick Quiz: ____________ is a technique that can be used to identify potential vulnerabilities

by listing the key assets of an application, categorizing the threats to each asset, ranking the threats, and developing threat mitigation strategies that can be implemented during coding. (Answer: Threat modeling.)

_________ categories help software developers anticipate threats from attackers. (Answer: STRIDE.)

True/False: Offensive programming is an approach to software development in which programmers anticipate what might go wrong as their programs run, and take steps to smoothly handle those situations. (Answer: False.)

Mitigation (728)LECTURE NOTES

Explain what can happen when bugs are discovered. Review the use of patches. Discuss the steps consumers can take to avoid security problems, as listed on

page 729.

TEACHER TIPSurvey students about their experience with software patches. Are they tolerant of (or exasperated by) the need to install patches to keep their computers safe from security threats?

FIGURES Figure 12-58

CLASSROOM ACTIVITIES1. Assign a Project: Have students design an attack tree for accessing a password-protected Web site, using as a model the attack tree shown in Figure 12-56.2. Quick Quiz:

Some of the most common examples of ______ error messages appear during unsuccessful login attempts. (Answer: verbose.)

True/False: Formal methods add little to the cost and time of software development, so they tend to be used very often. (Answer: False.)

Proprietary software can benefit from a(n) ________ with other in-house programmers.a. redirectionb. walkthrough(Answer: B)

c. input filteringd. factcheck

Page 17: Microsoft Office 2003virgil.azwestern.edu/~cvb/CIS120/Book Notes/NP11_IM_…  · Web viewThe Prolog Fact program uses the facts to make decisions and then produces a solution. Compare

Glossary of Key Terms agile methodology (681) algorith (689) API (687) argument (714) assembly language (677) assumption (680) attack tree (726) buffer overflow (723) class (702) class attribute (703) class hierarchy (704) code (674) component (687) computer programming (675) constant (680) control (683) control structures (695) debugger (685) decision table (714) declarative paradigm (713) defensive programming (726) encapsulation (712) event (684) event-driven paradigm (685) event-handling code (684) fact (713) fifth-generations languages (678) first-generation language (677) flowchart (692) form design grid (683) formal methods (725) fourth-generation languages (678) function (696) functional paradigm (713) high-level language (676) IDE (integrated development

environment) (686) inheritance (704) instantiation (717) iteration (698) keyword (676) known information (680) logic error (685) loop (698)

low-level language (676) message (706) method (705) multiparadigm languages (679) object (702) object-oriented paradigm (702) parameters (676) particle renderer (687) pathfinder algorithms (687) polymorphism (707) predicate (714) predictive methodology (681) private attribute (703) problem statement (680) procedural language (689) procedural paradigm (689) procedure (696) program editor (682) programming language (676) programming paradigm (679) properties (683) pseudocode (692) public attribute (703) remarks (686) repetition control structure (698) runtime error (685) SDK (software development kit)

(686) second-generation language (677) selection control structure (697) sequence control structure (695) sequential execution (695) signed code (727) structured English (692) subclass (704) subroutine (696) superclass (704) syntax (676) syntax error (685) third-generation languages (677) threat modeling (725) variable (680) VDE (visual development

environment) (683) walkthrough (694)

Top of Document