CBR Logo


CBR*Tools Documentation


B1.Abstract Factory


B2.Adapter


B3.Chain of Responsibility


B4.Composite


B5.Facade


B6.Factory Method


B7.Iterator


B8.Prototype


B9.Strategy


B10.Template Method


Logo of Inria at Sophia Antipolis


French flag - link to the french documentation


Return to the Action AID
main page

Annex B: Design Patterns

B2.Adapter

Description

This pattern is useful when we wish to use an existing class but the interface suggested is not satisfactory; the pattern then proposes to define, by multiple inheritance, a class carrying out the necessary actions of adaptation.

Structure and Components

Structure and Components of the Adapter design pattern

Structure and Components of the Adapter design pattern

  • RequestedInterface defines the interface wanted by the client,
  • ExistingInterface defines the existing interface of the objects to be handled,
  • Adpater carries out the actions necessary for the realisation of the operations according to the interface wanted while being based on the existing operations,
  • InterfaceClient handles the object according to the desired interface.

Collaborations

  • the customer handles the object by the wished interface,
  • the adapter carries out the actions of adaptation and uses the existing interface.

Strengths and Weaknesses

Plus sign allows the re-use of an existing class of objects in another context,

Minus sign it is not always possible to carry out actions of adaptation to implement this pattern.

Use in CBR*Tools

This pattern is used to connect two phases of reasoning: the first provides a type of results which do not conform with the expected ones from the second. This pattern is also used in the same manner to connect indices. However, in CBR*Tools, the application of this pattern is facilitated by the definition of hierarchy of interface classes (i.e. not defining any code). The adaptation thus avoids the call to existing code (which is not always adaptable) and arises in a symmetrical way between the interface of origin and the one that is desired. This type of adapter is known as bidirectional.




Valid XHTML 1.0! Valid CSS! Brigitte Trousse
Last modified: Wed Oct 3 16:04:10 MEST 2001