AP Computer Science Principles · Unit 3: Algorithms & Programming
3.13 Developing Procedures
Why use procedures?
A procedure (or function/method) is a named group of programming instructions that performs a task. Procedures let programmers manage complexity by breaking a large problem into smaller pieces. This supports abstraction: once a procedure works, you can call it by name without worrying about its internal details.
Parameters and return values
Procedures often take parameters — inputs that let the same procedure behave differently with different data. A procedure may also produce a return value, sending a result back to the code that called it. Procedures without return values instead perform actions like printing output or changing a variable's value (a side effect).
Documenting procedures
Good procedures include comments describing their purpose, inputs, and outputs, making them reusable by other programmers. Well-designed procedures also handle common edge cases, like unexpected or extreme input values, so the procedure behaves reliably no matter what data is passed in.
Key terms
- Procedure
- A named group of programming instructions that performs a specific task; also called a function or method.
- Parameter
- An input value passed into a procedure that can change its behavior or output.
- Return value
- The result a procedure sends back to the code that called it.
- Side effect
- An action a procedure performs, such as changing a variable or printing output, instead of (or in addition to) returning a value.
- Edge case
- An unusual or extreme input used to test whether a procedure behaves correctly under all conditions.
Try an AP-style question
What is procedural abstraction?
- Deleting any unused procedures in a file
- Writing every step inline in the program
- Using a procedure without knowing its code
- Encrypting all procedure names for safety
Show the answer
C. Hide implementation.
Practice 8 AP-style questions with instant explanations, flashcards and spaced review.
Study 3.13 free in APrep