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

B9.Strategy

Description

When there are several possible implementations of an algorithm and is necessary to choose one of them dynamically, this pattern proposes the delegation of the execution of this algorithm to interchangeable objects which respect a common interface.

Structure and Components

Structure and Components of the Strategy design pattern

Structure and Components of the Strategy design pattern

  • Strategy defines the calling interface of an algorithm,
  • Strategy1 , Strategy2 and Strategy3 establish alternatives of the same algorithm,
  • Context holds the context of execution.

Collaborations

  • Context starts the execution of the algorithm,
  • Strategy can need contextual data present in Context .

Strengths and Weaknesses

Plus sign allows the definition of family of algorithms,

Plus sign allows the choice of the algorithm in a dynamic way and adapted to the context,

Minus sign it can be difficult to foresee the representation of the parameters resulting from the context of execution which are transmitted in a way identical to all the concrete algorithms.

Use in CBR*Tools

This pattern is used for each phase of the reasoning (classes Retrieve , Resuse , Revise and Retain ), as well as in the realisation of the phases themselves (classes CaseSetAdpatationFormula and AnalysisAdpatationFormula ). It is also used for the filters of indices ( IndiceFilter class) and in the similarities (classes ValueSimilarityFct and AggregationFct ).




Valid XHTML 1.0! Valid CSS! Brigitte Trousse
Last modified: Fri Sep 28 13:52:30 MEST 2001