Java Reference
In-Depth Information
This illustrates that each object consists of data and the operations on those data. An
object combines data and operations on that data into a single unit. In OOD, the final
program is a collection of interacting objects. A programming language that implements
OOD is called an object-oriented programming (OOP) language. You will learn
about the many advantages of OOD in later chapters.
Because an object consists of data and operations on the data, before you can design and
use objects, you need to learn how to represent data in computer memory, how to
manipulate data, and how to implement operations. In Chapter 2, you will learn the basic
data types of Java and discover how to represent and manipulate data in computer
memory. Chapter 3 discusses how to input data into a Java program and output the
results generated by a Java program.
To create operations, you write algorithms and implement them in a programming
language. Because a data element in a complex program usually has many operations,
to separate operations from each other and use them effectively and in a convenient
manner, you use methods to implement algorithms. You will learn the details of
methods in Chapter 7. Certain algorithms require that a program make decisions, a
process called selection. Other algorithms might require that certain statements be
repeated until certain conditions are met, a process called repetition. Still other algorithms
might require both selection and repetition. You will learn about selection and repetition
mechanisms, called control structures, in Chapters 4 and 5.
Finally, to work with objects, you need to know how to combine data and operations on
that data into a single unit. In Java, the mechanism that allows you to combine data and
operations on the data into a single unit is called a class. In Chapter 8, you will learn how
to create your own classes.
In Chapter 9, using a mechanism called an array, you will learn how to manipulate data
when data items are of the same type, such as the items in a list of sales figures. As you can
see, you need to learn quite a few things before working with the OOD methodology.
For some problems, the structured approach to program design is very effective. Other
problems are better addressed by OOD. For example, if a problem requires manipulating
sets of numbers with mathematical functions, you might use the structured design
approach and outline the steps required to obtain the solution. The Java library supplies
a wealth of functions that you can use to manipulate numbers effectively. On the other
hand, if you want to write a program that would make a candy machine operational, the
OOD approach is more effective. Java was designed especially to implement OOD.
Furthermore, OOD works well and is used in conjunction with structured design. Chapter
6 explains how to use an existing class to create a Graphical User Interface (GUI) and then
gives several examples explaining how to solve problems using OOD concepts.
Both the structured design and OOD approaches require that you master the basic
components of a programming language to be an effective programmer. In the next
few chapters, you will learn the basic components of Java required by either approach to
programming.
Search WWH ::




Custom Search