Tony Johansson wrote:
I'm reading about design patter in the GAMMA book and there is something
that I don't understand.
That's why I ask you.
It says "Pluggable adpters. A class is more reusable when minimize the
assumption other classes must make to use it. By building interface
adaptation into a class, you eliminate the assumption that other classes see
the same interface. Put another way, interface adaptation lets us
incorporate our class into existing systems that might expect different
interfaces to the class."
Now the first row says "A class is more reusable when minimize the
assumption other classes must make to use it." I can't see why a class
should have any assumption about a class before being able to use it.
Now the second row what does this mean "By building interface adaptation
into a class, you eliminate the assumption that other classes see the same
interface."
Is there a C++ _language_ question here? Have you already visited the
'comp.object' newsgroup as I suggested or are you still waiting for some
sign from the heavens?
Every assumption you have to make about a class introduces a limitation
or several on the class, thus reducing the re-usability of the class.
When you design a type, you lay the foundation by introducing some
concepts, some assumptions, about the type and about the ways objects of
that type are going to be used. For example, when designing a _list_ you
assume that people will (a) add to the list, (b) remove from the list, and
(c) iterate over the list. Now, (a) and (b) are vague, so let's make the
assumptions that you should be able to insert at any point in the list and
remove any element from the list.
To use the list (or any other class pretending to be a list), you have to
make those assumptions above. And any class that "is-a" list (does not
necessarily mean it inherits from some 'class list') has to implement that
interface.
More in comp.object.
V