Design Patterns by Gamma et al says
The second criterion, called scope, specifies whether the pattern applies primarily to classes or to objects. Class patterns deal with relationships between classes and their subclasses. These relationships are established through inheritance, so they are static— fixed at compile-time. Object patterns deal with object relationships, which can be changed at run-time and are more dynamic. Almost all patterns use inheritance to some extent. So the only patterns labeled "class patterns" are those that focus on class relationships. Note that most patterns are in the Object scope.
How shall I tell if a design pattern is a class pattern or an object pattern?
Is it correct that a class pattern is established by class inheritance, and an object pattern is by object composition?
For example, why is factory method a class pattern
while abstract factory is an object pattern
?
Why is the first kind of adapter a class pattern, while the second kind of adapter an object pattern
?
Aucun commentaire:
Enregistrer un commentaire