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

B7.Iterator

Description

When we want to mask in the client the mechanics of course of an aggregate, this pattern allows the encapsulation of the iteration in a class hierarchy, either for polymorphic iterations, or to offer various types of tranersing for the same type of aggregate.

Structure and Components

Structure and Components of the Iterator design pattern

Structure and Components of the Iterator design pattern

  • Iterator defines the interface of iteration,
  • Iterator1 and Iterator2 establish two mechanisms of traversing,
  • Aggregate defines the interface of an aggregate,
  • Aggregate1 and Aggregate2 establish two types of concrete aggregates,
  • IteratorClient launches the iteration on the aggregate.

Collaborations

  • the client requests the creation of an object of iteration from the aggregate or another object responsible for the instantiation of the iterator,
  • the client controls the iteration (external iterator) by handling the iterator.

Strengths and Weaknesses

Plus sign allows to traverse an aggregate without knowing its internal structure,

Plus sign allows us to traverse in various manners the same aggregate,

Minus sign the aggregate can be obliged to export methods only so that the iterators can function.

Use in CBR*Tools

The Iterator pattern is used to traverse the recordings ( Record class) in the indexing by behavioural situations. Each type of recordings defines a traverse by defect adapted to its internal representation (properties of the chronicles of which it is made up). Moreover, the templates of potential cases ( PotentialCaseTemplate class) define their own traverse of a recording following their conditions of instantiation.




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