01 / 21

Program Design
and Development

Master the software development lifecycle: from planning and designing algorithms to collaborating, testing, and documenting your programs.

AP Computer Science Principles

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

Investigate Design Prototype Test Reflect Refine

Essential Vocabulary

Algorithm
A finite set of step-by-step instructions that solve a problem or perform a task.
Abstraction
Reducing complexity by focusing on the essential features while hiding unnecessary details.
Decomposition
Breaking a complex problem into smaller, more manageable sub-problems.
Pseudocode
A plain-language description of an algorithm's steps, independent of any programming language.
Flowchart
A visual diagram that represents the sequence, decisions, and flow of an algorithm.

The Power of Decomposition

Build a Game App User Interface Game Logic Data Storage Buttons Screens Menus Scoring Levels Collisions Save Files Leaderboard Each sub-problem can be solved independently, then combined.

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.

Pseudocode
Written in structured, human-readable text. Focuses on logic, not syntax.
Flowchart
Uses shapes and arrows to show the flow of decisions and processes visually.

Flowchart Symbols

Start / End Oval (Terminal) Process Rectangle (Action) Decision Diamond (Yes/No) Input / Output Parallelogram Flow Arrow Shows direction Each shape has a specific meaning in algorithmic design.

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.

1
Diverse perspectives lead to more creative and robust solutions that serve more users.
2
Pair programming involves one person writing code while another reviews it in real time.
3
Code reviews help identify bugs, improve readability, and share knowledge across a team.
4
Comments and documentation make collaboration possible by explaining what code does and why.

Two roles examine one bug from different viewpoints

Two collaborators share one programming workstation and examine a 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

Five correct Boolean answers enter a score trace that contrasts increment 2 with the corrected increment 1.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

1
Define the problem. What exactly should the program do? Who is it for?
2
Decompose the problem into smaller, independent sub-problems.
3
Write pseudocode or draw a flowchart for each sub-problem's algorithm.
4
Implement the code for one sub-problem at a time (incremental development).
5
Test each part as you go. Fix bugs before moving to the next feature.
6
Document your code with comments explaining purpose, inputs, and outputs.

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:

INPUT score
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

Start INPUT score
\( \ge 90\text{?} \)
"A" Yes
\( \ge 80\text{?} \)
No "B" Yes
\( \ge 70\text{?} \)
No "C" Yes ...continues for D and F

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 \):

// What does this display?
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.

In-line Comments
Short notes next to specific lines explaining what that line does.
Block Comments
Longer descriptions at the top of a function or program section explaining its purpose.
README Files
External documents that explain how to install, use, and contribute to a project.

Common Mistakes

✕ Skipping the Plan
Jumping straight to code without pseudocode or a flowchart leads to disorganized, buggy programs.
✕ No Decomposition
Trying to solve the entire problem at once makes it overwhelming and hard to debug.
✕ Testing at the End
Waiting until the program is "done" to test makes finding the source of bugs much harder.
✕ No Comments
Undocumented code is nearly impossible for others (or your future self) to understand or modify.
✕ Ignoring Edge Cases
Not considering unusual inputs (like zero, negative numbers, or empty strings) causes runtime errors.

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:

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?