< previous page page_162 next page >

Page 162
Let's begin our look at OOD by making an observation about top-down design. Top-down design can be thought of as the design of a problem solution by focusing on actions and algorithms. In top-down design, data plays a secondary role in support of actions to be performed.
In contrast, OOD focuses on entities (objects) and operations on those objects. For example, a banking problem may require a checkingAccount object with associated operations OpenAccount, WriteCheck, MakeDeposit, and IsOverdrawn. The checkingAccount object consists of both data (the account number and the current balance, for example) and operations, all bundled together.
The first step in OOD is to identify the major objects in the problem, together with their associated operations. The final problem solution is ultimately expressed in terms of these objects and operations. In OOD, data plays a leading role. Algorithms are used to implement operations on the objects and to guide the interaction of objects with each other.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif 3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
Object-Oriented Design A technique for developing a program in which the solution is expressed in terms of objectsself-contained entities composed of data and operations on that data.
Like top-down design, OOD uses the divide-and-conquer approach to problem solving. Both techniques break up large problems into smaller units that are easier to handle. The difference is that in top-down design the units are modules representing algorithms, whereas the units in OOD are objects.
Several programming languages, called object-oriented programming languages, have been created specifically to support OOD. Examples are C++, Smalltalk, CLOS, Eiffel, and Object-Pascal. In these languages, a class is a programmer-defined data type from which objects are created. Although we did not say it at the time, we have been using classes and objects to perform input and output in C++. cin is an object of a data type (class) named istream, and cout is an object of a class ostream. As we explained earlier, the header file iostream.h defines the classes istream and ostream and also declares cin and cout to be objects of those classes:
istream cin;
ostream cout;
Similarly, the header file fstream.h defines classes ifstream and ofstream, from which you can declare your own input file stream and output file stream objects.

 
< previous page page_162 next page >