3.13 Developing Procedures

Enduring Understanding

Programmers break down problems into smaller and more manageable pieces. By creating procedures and leveraging parameters, programmers generalize processes that can be reused. Procedures allow programmers to draw upon existing code that has already been tested, allowing them to write programs more quickly and with more confidence.

Learning Objective

Explain how the use of procedural abstraction manages complexity in a program. 

Essential Knowledge

One common type of abstraction is procedural abstraction, which provides a name for a process and allows a procedure to be used only knowing what it does, not how it does it.

Procedural abstraction allows a solution to a large problem to be based on the solutions of smaller subproblems. This is accomplished by creating procedures to solve each of the subproblems.

The subdivision of a computer program into separate subprograms is called modularity.

A procedural abstraction may extract shared features to generalize functionality instead of duplicating code. This allows for program code reuse, which helps manage complexity.

Using parameters allows procedures to be generalized, enabling the procedures to be reused with a range of input values or arguments.

Using procedural abstraction helps improve code readability.

Using procedural abstraction in a program allows programmers to change the internals of the procedure (to make it faster, more efficient, use less storage, etc.) without needing to notify users of the change as long as what the procedure does is preserved.

Learning Objective

Develop procedural abstractions to manage complexity in a program by writing procedures. 

Essential Knowledge

The exam reference sheet provides

Text:

PROCEDURE procName(parameter1, parameter2, ...)

{

<block of statements>

}

Block:

which is used to define a procedure that takes zero or more arguments. The procedure contains block of statements.

The exam reference sheet provides:

Text:

PROCEDURE procName(parameter1, parameter2, ...)

{

<block of statements>

RETURN(expression)

}

Block:

which is used to define a procedure that takes zero or more arguments. The procedure contains block of statements and returns the value of expression. The RETURN statement may appear at any point inside the procedure and causes an immediate return from the procedure back to the calling statement.

Last updated