|
Re: The Generic Adapter Pattern
|
Posted: Aug 15, 2005 7:17 PM
|
|
> I don't mean to berate your post or seem ignorant,
No worries.
> but > what exact benefit does this pattern give us? It appears > to work only (or mostly?) in adapting to a class from > another class which implements the correct methods with > matching signatures.
Voila, that's exactly what it does.
> How often would that be the case > where one didn't have access to the creation of both > classes, and could then simply make both inherit the > abstract class?
There are several possible scenarios: you don't have access to the classes (in some kind of library), or you don't want the class to have a vtable pointer, or you don't want dynamic dispatching in the class itself most of the time, or you don't want to break something which already works, ... those are the first few that jump to mind.
> Without the ability to add specific code > to deal with a specific class, wrapping its methods and > data structures into what the interface expects, it seems > very impractical.
As general practice the pattern is not advised, just something useful in some circumstances.
|
|