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.
How can we store data in a program to solve problems?
What might happen if you completed the steps in your regular morning routine to get ready and go to school in a different order? How might the reordering affect the decisions you make each morning?
How do video games group different actions for a player based on what key is pressed on the keyboard or controller? How do apps group different actions together based on user interaction, such as pressing buttons?
What types of problems can be solved more easily with a computer, and what types can be solved more easily without a computer? Why?
For procedure calls:
Write statements to call procedures.
Determine the result or effect of a procedure call.
Explain how the use of procedural abstraction manages complexity in a program.
Develop procedural abstractions to manage complexity in a program by writing procedures.
Select appropriate libraries or existing code segments to use in creating new programs.
A procedure is a named group of programming instructions that may have parameters and return values.
Procedures are referred to by different names, such as method or function, depending on the programming language.
Parameters are input variables of a procedure.
Arguments specify the values of the parameters when a procedure is called.
A procedure call interrupts the sequential execution of statements, causing the program to execute the statements within the procedure before continuing. Once the last statement in the procedure (or a return statement) has executed, flow of control is returned to the point immediately following where the procedure was called.
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 solution 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.