The logic may be the same, but in the OO approach we
think of a Vehicle object having ???behaviors??? appropriate to the application. When a Vehicle enters
the Thruway, we will call the Vehicle??™s enterThruway method, and the Vehicle object will deal
appropriately with that event.
The data one operates on and the logic one encodes may be the same for the procedural approach and
the object-oriented approach, but the object-oriented approach organizes the work differently. When an objectoriented
program is complete, a set of classes is the result. These classes, if well designed, can be reused
and extended more easily so that future programming projects have a head start.
Putting the code inside classes also allows functionality to be encapsulated, which leads to more effective
testing and more reliable use later on. The software classes exist as their own entities, with known properties
(attributes), and well-defined methods. Using inheritance, the OO approach also offers a standard way to add
functionality without changing at all the code that has already been written. There is less temptation to modify
the classes that have already been defined, implemented and tested. The result is usually more stable and
reliable code.
Pages:
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215