Although gratifying, attaining such in-depth knowledge of an item??™s inner
workings isn??™t a requirement. For example, millions of people use a computer every
day, yet few know how it actually works. The same idea applies to automobiles,
microwaves, and any number of other items. We can get away with such ignorance
through the use of interfaces. For example, you know that turning the radio dial
allows you to change radio stations; never mind the fact that what you??™re actually
doing is telling the radio to listen to the signal transmitted at a particular frequency,
a feat accomplished using a demodulator. Failing to understand this process does not
prevent you from using the radio because the interface takes care to hide such details.
The practice of separating the user from the true inner workings of an application
through well-known interfaces is known as encapsulation.
Object-oriented programming promotes the same notion of hiding the inner
workings of the application by publishing well-defined interfaces from which each
CHAPTER 6 ?– O BJECT-ORIENTED PHP 165
application component can be accessed. Rather than get bogged down in the gory
details, OOP-minded developers design each application component so that it is
independent from the others, which not only encourages reuse but also enables the
developer to assemble components like a puzzle rather than tightly lash, or couple,
them together.
Pages:
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244