Вопрос

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?

Нет правильного решения

Другие советы

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top