📚

All Subjects

 > 

⌨️ 

AP Comp Sci P

 > 

📱

Big Idea 3: Algorithms and Programming

Developing Procedures

2 min read•november 16, 2020

minnachow

Minna Chow


AP Computer Science Principles ⌨️

Bookmarked 2.3k • 69 resources
See Units

3.13 Developing Procedures

Procedures are an example of abstraction. (In fact, it's part a special form of abstraction known as procedural abstraction.) This is because you can call a procedure without knowing how it works. Indeed, you often do: a common built-in procedure in programming languages is the print() procedure.
Procedures allow you to solve a large problem based on the solution to smaller sub-problems. For example, my final Create project was a choose-your-own-adventure story. In order to make this story, I had to figure out how to let players choose what path they were going to take, how to display this path choice, how to track a player's progress in the game so their actions would have consequences... and so on. I solved the larger "problem" of writing a choose-your-own-adventure story by solving all these smaller problems with procedures I then combined.
When you divide a computer program into separate sub-programs, it's known as modularity.
Procedures can also help you simplify your code and improve its readability.
Instead of this:
first_number = 7 second_number = 5 sum_value = first_number + second_number print (sum_value) first_number = 8 second_number = 2 sum_value = first_number + second_number print (sum_value) first_number = 9 second_number = 3 sum_value = first_number + second_number print (sum_value)
you get this:
def summing_machine(first_number, second_number): sum_value = first_number + second_number print (sum_value) summing_machine(5, 7) summing_machine(8, 2) summing_machine(9, 3)
Isn't the second example a lot easier to understand? This is especially important in larger programs, where you might already be looking at hundreds of lines of code.
The beauty of procedures is how they can be reused. Parameters usually represent general categories of data, such as numbers or strings. This means you could use one procedure for a wide range of individual scenarios.
Procedural abstraction also allows programmers the flexibility to modify or fix procedures without affecting the whole program, as long as the procedure continues to function in the same way. Furthermore, they can make a change or edit once, in the procedure, and it will be implemented everywhere where the procedure is called.

Was this guide helpful?

Join us on Discord
Thousands of students are studying with us for the AP Computer Science Principles exam.
join now
Hours Logo
Studying with Hours = the ultimate focus mode
Start a free study session
🔍 Are you ready for college apps?
Take this quiz and find out!
Start Quiz
Browse Study Guides By Unit
🕹Big Idea 1: Creative Development
⚙️Big Idea 2: Data
📱Big Idea 3: Algorithms and Programming
🖥Big Idea 4: Computer Systems and Networks
⌨️Big Idea 5: Impact of Computing
✏️Blogs
📝Exam Prep
Join us on Discord
Thousands of students are studying with us for the AP Computer Science Principles exam.
join now
💪🏽 Are you ready for the AP CSP exam?
Take this quiz for a progress check on what you’ve learned this year and get a personalized study plan to grab that 5!
START QUIZ