
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Key Object-Oriented Programming Concepts
|
17
they can change without necessitating changes in the rest of the program. As long as
the method names (and their parameters and return values) stay the same, the rest of
the program can continue to use the object without being rewritten.
Encapsulation is an important aspect of object-oriented design because it allows dif-
ferent programmers to work on different classes independently. As long as they agree
on the names of the public methods through which they’ll communicate, the classes
can be developed independently. Furthermore, by developing a specification that
shows the publicly available methods, the parameters they require, and the values
they return, a class can be tested thoroughly before being deployed. The same test
code can be used to reverify the class’s operation even if the code within the class is
refactored (i.e., rewritten to enhance performance or to simplify the source code
without changing the previously existing functionality).
In Chapter 4, we’ll learn how to use the private modifier to prevent a method or
property from being accessed by other parts of a program.
Datatypes
Each class in an object-oriented program can be thought of as defining a unique kind
of data, which is formally represented as a datatype in the program. ...