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

B4.Composite

Description

When we wish to represent a tree structure or to mask the differences between composite and simple objects of similar nature, the composite pattern proposes the definition of a unified interface of simple and composite objects.

Structure and Components

Structure and Components of the Composite design pattern 1

Structure and Components of the Composite design pattern 1

Structure and Components of the Composite design pattern 2

Structure and Components of the Composite design pattern 2

  • Component defines the abstract interface of a simple or composite component,
  • .
  • Leaf defines the behavior of a component breaks into leaf, i.e. which cannot have wire,
  • Composite defines the behavior of a composite by storing its sons and by reflecting the processing of the methods in its sons in an adapted way,
  • ComponentClient handles the components.

Collaborations

The clients handle a component through its general interface. A leaf directly executes the operations required, whereas a composite transfers the requests to its children by performing the additional actions prior or after their transfer.

Collaborations of the Composite design pattern

Collaborations of the Composite design pattern

Strengths and Weaknesses

Plus sign arborescent structuring of objects: a composite which joins together sub-components can be integrated in a composite,

Plus sign encapsulation of the heterogeneity of simple and composite objects: a composite object can be used in the place of a simple object and vice versa,

Plus sign facilitated integration of new classes of composite or simple objects which can be combined in a stable way,

Minus sign necessity to dynamically control particular constraints in the composition of objects within a composite,

Minus sign the maximisation of the general interface of a component (necessary for the encapsulation) can bring to the declaration of methods which do not make sense for simple objects.

Use in CBR*Tools

This pattern is used to represent in a structured way the indices, the similarities, the case bases and the indices.




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