Lesson 20. Building programs to last

 

After reading lesson 20, you’ll be able to

  • Understand how a bigger task is divided into modules
  • Understand why you should hide away details of complicated tasks
  • Understand what it means for tasks to be dependent on or independent of other tasks

You saw how useful loops are at getting the computer to repeat a certain group of statements many times. As you’re writing code, it’s important to be aware of how you can harness the power of computers to make life easier for you. In this lesson, you’ll take this idea a step further to see how to divide a larger program into smaller mini-programs, each one constructed to achieve a specific task.

For example, if you think about the process of building a car as a large program, you’d never build one machine that builds the entire car. That would be one extremely complicated machine. Instead, you’d build various machines and robots that focus on doing different and specific tasks: one machine might assemble the frame, one might paint the frame, and another might program the on-board computer.

Consider this

You’re getting married! You don’t have time to take care of everything on your own, so you want to hire people to take care of various tasks. Write some tasks that you can outsource.

Answer: Find and book venue, decide on catering (food, bar, cake), finalize guest list (invite people, keep track of attendees, seating), decorate, hire officiant, and dress up the wedding party.

20.1. Breaking a big task into smaller tasks

 
 
 

20.2. Introducing black boxes of code in programming

 

20.3. Subtasks exist in their own environments

 
 
 
 

Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage