It is not the strongest of the species that survives, nor the most intelligent that survives. It is the one that is the most adaptable to change.
The measure of intelligence is the ability to change.
Science always has its origin in the adaptation of thought to some definite field of experience.
This chapter is a two-for-one package: object and class Adapters. This chapter has many lessons, but one of the most interesting is seeing the difference between using inheritance and using composition. The class scope version of the Adapter design pattern uses inheritance, as can be seen in the class diagram in Figure 7-1.
In the class diagram, one implementation of the pattern is to have one class with dual inheritance. As you will see, dual inheritance is not allowed in PHP 5, but there are alternatives to dual inheritance where the pattern can be correctly implemented with a combination of inheritance and implementation.
As you know, an important dictum of design patterns is to favor
composition over inheritance. In looking at the second Adapter pattern,
Adapter participant uses composition to hold a
reference to the
Adaptee instead of inheritance.
Generally, composition is favored over inheritance ...