Question

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?

No correct solution

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top