Programing Logic ch9

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/55

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

56 Terms

1
New cards

Method:

A program module that contains a series of statements that carry out a task.

2
New cards

Method header:

also called the declaration or definition

3
New cards

Method body:

Contains the implementation (Statements that carry out the tasks).

4
New cards

Method return statement:

Returns control to the calling method.

5
New cards

Method must include

Method header, Method body, and Method return statement.

6
New cards

Local Variables and constants:

declared in a method

7
New cards

Global Variables and constants:

known to all program modules

8
New cards

When methods must share data:

Pass the data into and return the data out of methods.

9
New cards

When you call a method from a program, you must know four things:

What the method does. Name of the called method. Type of information to send to the method, if any. Type of return data to expect from the method, if any.

10
New cards

Argument to the method:

Pass a data item into a method from a calling program.

11
New cards

Parameter to the method:

Method receives the data item.

12
New cards

When a method receives a parameter, you must provide a parameter list that includes:

The type of the parameter. The local name for the parameter.

13
New cards

Signature:

Method’s name and parameter list.

14
New cards

Passed by value:

A copy of a value is sent to the method and stored in a new memory location accessible to the method.

15
New cards

Methods can require more than one parameter.

List the arguments within the method call, separated by commas. List a data type and local identifier for each parameter within the method header’s parentheses. Variables that accept the parameters in the method are called formal parameters.

16
New cards

Creating Methods that Require Parameters.

Passed by value. Each time a method executes, parameter variables listed in the method header are redeclared.

17
New cards

A variable declared within a method ceases to exist when the method

Goes out of scope.

18
New cards

To retain a value that exists when a method ends,

return the value from the method back to the calling method

19
New cards

Return type for a method

Indicates the data type of the value that the method will send back. Can be any type. Also called method’s type. Listed in front of the method name when the method is defined.

20
New cards

Overhead refers to

the extra resources and time required by an operation, such as calling a method.

21
New cards

IPO chart:

A tool that identifies and categorizes each item in a method by input, processing, and output. A method that finds the smallest of three numeric values.

22
New cards

Indicate that a method parameter must be an array.

Place square brackets after the data type in the method’s parameter list.

23
New cards

Arrays are passed by reference.

the method receives the actual memory address of the array and has access to the actual values in the array elements.

24
New cards

Method can also return nothing.

Return type void, Void method.

25
New cards

Overloading:

Involves supplying diverse meanings for a single identifier.

26
New cards

Overload a method:

Write multiple methods with a shared name but different parameter lists.

27
New cards

Polymorphism:

Ability of a method to act appropriately according to the context.

28
New cards

Ambiguous methods:

Situations in which the compiler cannot determine which method to use.

29
New cards

Every time you call a method:

Compiler decides whether a suitable method exists. If so, the method executes. If not, you receive an error message.

30
New cards

Using Predefined Methods:

Modern programming languages contain many methods that have already been written.

31
New cards

Implementation hiding:

Encapsulation of method details. When a program makes a request to a method, it does not know the details of how the method is executed.

32
New cards

Interface to the method

The only part of a method with which the method’s client interacts.

33
New cards

Substitute a new method implementation

As long as the interface does not change, you do not need to make changes in any methods that call the altered method

34
New cards

a black box is

A hidden implementation. You can examine what goes in and out but not how it works.

35
New cards

Cohesion:

How the internal statements of a method serve to accomplish the method’s purpose.

36
New cards

Coupling:

A measure of the strength of the connection between two program methods.

37
New cards

Tight coupling:

Occurs when methods excessively depend on each other. Makes programs more prone to errors. Methods have access to the same globally defined variables.

38
New cards

Loose coupling:

Occurs when methods do not depend on others. Data is passed from one method to another.

39
New cards

Recursion:

Occurs when a method is defined in terms of itself. Calls itself.

40
New cards

Every time you call a method The address to which the program should return is stored in a memory location called

the stack.

41
New cards

Recursive cases:

input values that cause a method to recur.

42
New cards

Base case or terminating case:

input values that makes the recursion stop.

43
New cards

Procedure(s)

A ________ is a block of Visual Basic code that performs a task. Code that is repeated more than once in a program could be put into a ________. Using ________ makes it easier for you and for other programmers to read and maintain your code.

44
New cards

a method is called a ________ in visual basic.

procedure

45
New cards

Sub Procedures

do not return a value back to their calling procedure.

46
New cards

Function Procedures

do return a value back to their calling procedure. you have to indicate the type of data it will return.

47
New cards

the function called Format()

allows you to control the format of numeric output. For example, it can be used to display a number as currency (money).

48
New cards

You can also pass a _________ element to a Sub procedure or Function, just as you pass a variable or constant.

single array

49
New cards

A program can contain a method that

calls another method.

50
New cards

Programmers should strive to _____.

increase cohesion

51
New cards

A method’s interface is its _____.

parameter list, return type, and identifier.

52
New cards

When you use a variable name in a method call, it _____ as the variable in the method header.

can have the same name

53
New cards

When an array is passed to a method, it is _____.

passed by reference

54
New cards

When a method receives a copy of the value stored in an argument used in the method call, it means the variable was _____.

passed by value

55
New cards

Although the terms parameter and argument are closely related, the difference is that argument refers to _____.

a value in a method call

56
New cards

When you write the declaration for a method that can receive a parameter, which of the following must be included in the method declaration?

A local name for the parameter, and the data type of the parameter.