1.2 Application Development

When writing a program, it is important to keep in mind that the computer will do exactly what you tell it to do. It cannot think as a human would, so you must provide clear instructions for every step.

When giving instructions to others, people will often fill in blanks in logic without even realizing it. For example, if you instruct someone to “go to the bank,” you may not say what mode of transportation should be used. A computer, however, does not have the ability to “fill in the blanks.” A computer will only do exactly what you tell it to do.

Imagine, for example, explaining to a person and to a computer how to make a peanut butter and jelly sandwich. To the person, all you might need to say is, “Spread the peanut butter on one slice of bread, the jelly on the other slice of bread, and then put the pieces of bread together.” If these instructions were given to a computer, however, the computer would not know where to start. Implied in these instructions are many logical steps that a human can automatically infer and the computer cannot. For example, the human would know that the jar must first be opened to scoop peanut butter out before you can spread it onto a slice of bread. The computer might try to spread the actual jar across the bread, without taking the peanut butter or jelly out—assuming it could even find them!

Computer science is ultimately about problem solving. The following is a basic approach to solving problems:

Step 1: Understand ...

Get Computer Science Programming Basics in Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.