AP Computer Science Principles · Unit 1 lecture · Part 6 of 11 · 7 min

1.3 Investigating and designingFind out what people need, then plan it

Mr. Thompkins
The most expensive bug is a program that works perfectly and solves the wrong problem. Investigation is how you avoid it, and design is how you turn what you learned into a plan.

The design phase starts with investigation: finding out what the program must do. The course names four ways to collect that information from users: surveys, interviews, direct observations, and user testing. Each tells you something different.

MethodWhat you learnExample
SurveyAnswers from many people, quickly200 students rate how they study
InterviewDeep reasons from a few peopleTalk 20 minutes with two coaches
Direct observationWhat people really doWatch shoppers use a self-checkout
User testingWhere a prototype confuses peopleFive users try to add a task
Four ways to investigate. Surveys reach many people; interviews go deep; observation shows real behavior; user testing shows where a prototype confuses people.

What you learn becomes the program requirements: descriptions of how the program functions, which may include descriptions of user interactions it must provide. A program's specification is the document that defines its requirements. Requirements are the contract. They tell the team what to build and, later, what to test.

RequirementKindHow you would test it
R1. A user can add a task with a due dateWhat it must doAdd "Lab report, Friday"; it appears in the list
R2. A finished task can be checked offUser interactionTap the box; the task moves to Done
R3. The timer can be set from 5 to 60 minutesRange of inputsTry 4, 5, 60 and 61
R4. The chart shows the last 7 daysOutputEnter 8 days of data; only 7 bars appear
Sample requirements for a study app. Every requirement should be testable: you can say what input to try and what should happen.
?Wait, what's a user interface?
The user interface (UI) is the part of a program people see and touch: screens, buttons, menus, text boxes. A diagram of the UI layout shows where each element goes before anyone writes code.

Then comes the planning itself. Design can include brainstorming, planning and storyboarding (drawing each screen in order, like a comic strip of the app), organizing the program into modules and functional components, creating diagrams that show the layout of the user interface, and developing a testing strategy, meaning deciding how you will test each part before you build it.

Organizing into modules deserves a picture. Big programs are too complicated to think about all at once, so designers decompose them: break the program into a few large parts, then break each part into smaller jobs. Each small job is something one person can build and test on its own, which fits incremental development perfectly.

Study Buddy appTask listFocus timerProgress chartadd a taskmark it donecount downplay a chimetotal minutesdraw the barseach box can be built and tested on its own
Decomposition: the whole app, its modules, and the small jobs inside each module.
?Wait, what does "decompose" mean in computing?
To decompose a problem is to break it into smaller, simpler problems that can be solved one at a time and then combined. It's the same idea as incremental development, applied while planning.
Pause and think
A team wants to know why so many students leave the school library's online catalog after only a few seconds. Would a survey or direct observation tell them more? Why?
I thought about it. Show me
Direct observation, or user testing. Students may not remember or know why they leave, so a survey might get vague answers. Watching them use the catalog shows exactly where they get stuck, like a search box that is hard to find.
From need to requirements
A coach wants an app so her cross-country runners can log runs and she can see who is training too much. Plan the start of the design: (a) choose two investigation methods and say what each would reveal, (b) write two testable requirements, (c) name two modules.
  1. (a) Interviews with the coach, to learn exactly what "training too much" means to her (for example, more than 40 miles in a week). A survey of the runners, to learn how and when they would log runs (phone, right after practice).
    Why?
    Different methods for different questions: depth from the coach, breadth from the team.
  2. (b) R1: A runner can log a run with a date and a distance in miles. R2: The coach sees a warning next to any runner whose total for the last 7 days is over 40 miles.
    Why?
    Each requirement says what the program must do in a way you could test. R2 even has a cutoff to test at 40 and 41.
  3. (c) Modules: Run log (entering and saving runs) and Coach dashboard (weekly totals and warnings).
    Why?
    Each module can be built and tested on its own, then combined.

Answer: For example: interview the coach and survey the runners; R1 a runner can log date and miles, R2 the coach sees a warning above 40 miles in 7 days; modules for the run log and the coach dashboard.

Stuck? Get a hint
  1. Who has the information you need? The coach knows the rule; the runners know their habits.
  2. A testable requirement says exactly what happens, often with a number.
  3. Modules are the big parts: one for runners, one for the coach.
Check yourself
During design, a team draws each screen of its app in order, showing what happens after each tap, before writing any code. This is an example of
  1. Adebugging
  2. Bstoryboarding
  3. Cincremental testing
  4. Ddocumentation of a run-time error
Show the answer

B. Drawing the screens in sequence is storyboarding, one of the design activities the course lists. No code exists yet, so it can't be debugging or testing.

Check yourself
Which is the best example of a program requirement?
  1. AThe app should be good.
  2. BThe app uses blue buttons because the team likes blue.
  3. CA user can set a reminder for any time from 5 minutes to 24 hours in the future.
  4. DThe team will meet every Tuesday.
Show the answer

C. A requirement describes how the program must function, including user interactions, and it can be tested (try 4 minutes, 5 minutes, 24 hours). "Should be good" can't be tested, and the meeting schedule is about the team, not the program.

  • Investigate with surveys, interviews, direct observation and user testing.
  • Program requirements describe how the program functions, including user interactions. A specification defines them.
  • Design activities: brainstorming, storyboarding, organizing into modules, UI layout diagrams, planning a testing strategy.
  • Decompose a big program into modules and small jobs that can be built and tested one at a time.