O'Reilly logo

.NET Design Patterns by Shine Xavier, Praseed Pai

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Composite and visitor pattern - A quick primer

Whenever we deal with hierarchies like W3C DOM, document formats, graphics database or abstract syntax tree (AST) of a compiler, we create part/whole relationship. The GoF composite pattern is natural choice for creating hierarchies. Building hierarchies and its processing can be separated using GoF visitor pattern. The visitor pattern visits each node in the hierarchy and perform some action on the node. In a compiler, the tree representation of a program will be processed for type checking, code generation, trans compilation (source to source transformation) and so on. Sometimes people would like to perform additional activities on the tree. It is not feasible to add methods for processing the nodes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required