O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

The visitor design pattern

2.724 visualizações

Publicada em

Publicada em: Educação
  • Login to see the comments

The visitor design pattern

  1. 1. The Visitor Design Pattern<br />SamnangChhun<br />Yoolk Inc.<br />
  2. 2. Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.<br />What this?<br />Open Closed Principle is the key<br />The Visitor Design Pattern<br />
  3. 3. Structure<br />
  4. 4. Example<br />
  5. 5. Consequences<br />Benefits<br />Adding new operations is easy<br />Related behavior isn’t spread over the classes defining the object structure; it’s localized in a visitor. Unrelated sets of behavior are partitioned in own visitor subclasses.<br />Liabilities<br />Adding new ConcreteElement class is hard. Each new ConcreteElement give rise to a new abstract operation on Visitor and a corresponding implementation in every ConcreteVisitor class.<br />The ConcreteElement interface must be powerful enough to let visitors do their job. You may be forced to provide public operations that access an element’s internal state, which may compromise its encapsulation.<br />
  6. 6. Don’t forget to review all of them again and again<br />
  7. 7. Thank you!<br />

×