Program Design
and Development
Master the software development lifecycle: from planning and designing algorithms to collaborating, testing, and documenting your programs.
What Is Program Design?
Program design is the process of planning how a program will work before writing any code. It includes identifying the problem, breaking it into smaller parts, and outlining the steps your program will follow to reach a solution.
The Development Lifecycle
Essential Vocabulary
The Power of Decomposition
Representing Algorithms
An algorithm can be represented in multiple ways. The two most common in AP CSP are pseudocode (structured English) and flowcharts (visual diagrams). Both describe the same logic: they just use different formats.
Flowchart Symbols
Iterative vs Incremental
| Iterative | Incremental | |
|---|---|---|
| Approach | Revisit and refine the whole program in cycles | Build the program piece by piece |
| Focus | Improving existing features | Adding new features one at a time |
| Testing | Test after each cycle of refinement | Test each new component as it's added |
| Example | Draft → Revise → Revise → Final | Login → Profile → Feed → Chat |
Why Collaboration Matters
Effective programs are rarely built alone. Collaboration brings diverse perspectives, reduces individual bias, and helps catch errors early. The AP CSP exam emphasizes that collaboration is a critical part of the development process.
Two roles examine one bug from different viewpoints
The driver edits the program while the navigator checks its behavior against the intended result. Switching roles lets both collaborators examine the code and its tests.Use a test to find the doubled score
For five correct answers, the expected score is 5. An erroneous increment of 2 produces 10; changing the increment to 1 produces 5 for this test. The navigator checks the contract while the driver makes the edit, then they switch roles.Step-by-Step Design Process
Example: Pseudocode for a Grading Program
A teacher wants a program that takes a student's numeric score and outputs a letter grade. Let's design the algorithm in pseudocode:
IF \( \text{score} \ge 90 \)
DISPLAY "A"
ELSE IF \( \text{score} \ge 80 \)
DISPLAY "B"
ELSE IF \( \text{score} \ge 70 \)
DISPLAY "C"
ELSE IF \( \text{score} \ge 60 \)
DISPLAY "D"
ELSE
DISPLAY "F"
Example: Flowchart for the Grading Program
Tracing an Algorithm
On the AP exam, you'll be asked to trace code: follow each line step by step to determine the output. Let's trace this algorithm with input \( x = 5 \):
SET x TO 5
SET result TO 0
REPEAT x TIMES
\( \text{result} \leftarrow \text{result} + \text{x} \)
DISPLAY result
The Role of Documentation
Documentation includes comments within the code and external descriptions of how the program works. It makes programs easier to understand, debug, and maintain: especially when collaborating.
Common Mistakes
Summary: Key Concepts
| Concept | What It Means | Why It Matters |
|---|---|---|
| Decomposition | Break big problems into small ones | Makes problems manageable |
| Abstraction | Hide unnecessary details | Simplifies complex systems |
| Algorithm | Step-by-step instructions | Core of every program |
| Iteration | Refine through repeated cycles | Produces better solutions |
| Collaboration | Work together on solutions | Diverse ideas, fewer bugs |
| Documentation | Explain what code does and why | Enables teamwork and maintenance |
Question 1 of 5
Which of the following best describes the purpose of decomposition in program design?
Question 2 of 5
A programmer writes the following pseudocode:
SET total TO 0
SET count TO 1
REPEAT UNTIL \( \text{count} > 4 \)
\( \text{total} \leftarrow \text{total} + \text{count} \)
\( \text{count} \leftarrow \text{count} + 1 \)
DISPLAY total
What value is displayed?
Question 3 of 5
Which of the following is a benefit of using iterative development?
Question 4 of 5
In a flowchart, which shape is used to represent a decision (a point where the program chooses between two paths)?
Question 5 of 5
Two students are working on a program together. Student A writes the code while Student B reviews each line as it is typed. Which collaborative technique are they using?