Frage

I can't really come to terms with what makes the visitor design pattern different to a component design pattern. Both seem to just involve containers made up of discrete components.

So what's the difference?

Keine korrekte Lösung

Andere Tipps

Do you mean composite design pattern? If so, there is a similarity with both patterns in the aggregate portion.

However, in Visitor, operations are not done by the elements in the aggregate structure. They are rather encapsulated in visitor objects that examine (visit) elements of the composite. It allows adding operations easily without changing the aggregate classes.

Visitor can apply to an aggregate that is not necessarily a composite structure. So visitor and composite can be totally different patterns.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top