Pergunta

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?

Nenhuma solução correta

Outras dicas

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top