AP Computer Science Principles · Unit 3: Algorithms & Programming
3.14 Libraries
What are program libraries?
A library is a collection of pre-written procedures (methods/functions) that programmers can use in their own programs. Libraries let programmers reuse code others have written and tested, so they don't have to solve the same problem from scratch. This saves time and reduces errors.
Why libraries matter
Using libraries makes programs easier to develop, debug, and maintain because complex tasks are already implemented and tested by others. Libraries support abstraction: you can call a procedure without knowing exactly how it works internally, as long as you know its inputs and outputs (its interface).
APIs and calling library code
An API (Application Programming Interface) is a set of specifications, like available procedures and their parameters, that let programs communicate with each other or use a library. Programmers call library procedures using their documented names and parameters, without needing to see or understand the underlying code.
Key terms
- Library (programming)
- A collection of pre-written, reusable procedures programmers can call in their own programs.
- API
- Application Programming Interface — a set of specifications for how programs communicate with each other or use a library.
- Benefit of using libraries
- Saves time, reduces errors, and simplifies development by reusing tested code instead of writing it from scratch.
- Abstraction (in libraries)
- Using a procedure based on its inputs/outputs without needing to know how it's implemented internally.
- Calling a library procedure
- Using a documented procedure's name and parameters from a library to perform a task in your program.
Try an AP-style question
What is a software library?
- A type of variable
- A collection of reusable procedures
- A place to store paper books
- A compressed file
Show the answer
B. Prewritten code.
Practice 8 AP-style questions with instant explanations, flashcards and spaced review.
Study 3.14 free in APrep