Composite

パターンの目的

部分−全体階層を表現するために、オブジェクトを木構造に組み立てる。 Composite パターンにより、クライアントは、個々のオブジェクトとオブジェクトを合成したものを一様に扱うことができるようになる。

GoF パターンのクラス図

structure-08-05:composite

MixJuice 版 Composite (改善)

解決される GoF パターンの問題点

導入可能性の問題点
既存のクラスを Composite パターンの一部として扱えない。

対策

MixJuice では、スーパーインターフェース追加により後から Composite パターンの要素にできる。

結果

構造

module original {

define class C { ... }

} module extension extends original {

define interface Component { ... }
class C implements Component { ... }

}


MixJuice によるデザインパターン改善カタログ


田中 哲 <akr@m17n.org>, 一杉 裕志 <y-ichisugi@aist.go.jp>