Programming and Problem Solving with Java

(やまだぃちぅ) #1

(^4) | Introduction to Object-Oriented Programming


1.1 Overview of Object-Oriented Programming


Learning to program a computer is a matter of training yourself to solve problems in a very
detailed and organized manner. You are already experienced in solving problems intuitively,
but now you must develop the skill of writing a problem solution in terms of objects and ac-
tions that are appropriate for a computer. In this chapter we begin developing this skill by
answering some of the most commonly asked questions about programming and comput-
ers, and we then look at some formal techniques for solving problems.

What Is Programming?


Much of human behavior and thought is characterized by logical sequences of actions involv-
ing objects. Since infancy, you have been learning how to act, how to do things. And you have
learned to expect certain behaviors from everything you encounter in the world around you.
A lot of what you do every day you do automatically. Fortunately, you do not need to con-
sciously think of every step involved in a process as simple as turning a page by hand:

1.Lift hand.
2.Move hand to right side of book.
3.Grasp top-right corner of page.
4.Move hand from right to left until page is positioned so that you can read what is
on the other side.
5.Release page.

Think how many neurons must fire and how many muscles must respond, all in a cer-
tain order or sequence, to move your arm and hand. Yet you move them unconsciously.
Much of what you now do quite naturally you once had to learn. Watch how a baby con-
centrates on putting one foot before the other while learning to walk. Then watch a group
of three-year-olds playing tag. How far they have come!
On a broader scale, mathematics never could have been developed without log-
ical sequences of steps for manipulating symbols to solve problems and prove
theorems. Mass production never would have worked without operations taking
place on component parts in a certain order. Our entire civilization is based on the
order of actions, the logical arrangement of things, and their interactions.
We create order, both consciously and unconsciously, through a process called
programming. This book is concerned with the programming of one particular tool—
the computer.
Notice that the key word in the definition of a computer is data. Computers ma-
nipulate data. When you write a program (a plan) for a computer, you specify the properties
of the data and the operations that can be applied to it. The combination of the data and op-

Programming Developing in-
structions for carrying out a task
involving a set of objects
Computer A programmable
device that can store, retrieve,
and process data
Free download pdf