The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
110 views

Traversing an AST using Visitors

I'm writing a compiler for a C-like language, and I'm looking for an elegant way to traverse my abstract syntax tree. I'm trying to implement the Visitor pattern, although I'm not convinced that I'm ...
1
vote
2answers
120 views

Visitor only applicable when using the Composite pattern?

For a long time I've tried to get my head wrapped around the visitor pattern, and somehow this thing keeps being rather fuzzy to me. I'm currently under the impression it is only useful to apply ...
1
vote
2answers
149 views

Validating objects with each other - Design Pattern needed

I am running a zoo application. My zoo includes an abstract class of 'animal', and several deriving classes - 'zebra', 'elephant', 'orangutan', 'baboon' and so on. Of each class I have several ...
0
votes
2answers
388 views

Design for a tree using a visitor pattern, how to implement different kinds of traversal?

I've been asked a theoretical design question with an eye upon the GoF patterns.: "Given a design for a tree using a standard visitor pattern, how would your design look to allow a user to choose ...
4
votes
4answers
203 views

Visitor Pattern still useful in languages supporting class extensions?

Is the visitor pattern useful in languages supporting class extensions? Why bother implementing it, when you have open classes or can subclass. If you want new functionality for a class you could ...
13
votes
3answers
4k views

Implementing the Visitor Pattern for an Abstract Syntax Tree

I'm in the process of creating my own programming language, which I do for learning purposes. I already wrote the lexer and a recursive descent parser for a subset of my language (I currently support ...
1
vote
1answer
204 views

Visitor pattern [closed]

I was recently given the following task, and failed, the reason given that I misunderstood the question Create a 'LibraryItem' interface. Create 3 concrete implementations of LibraryItem: 'Book', ...
9
votes
1answer
1k views

Using visitor pattern with large object hierarchy

Context I've been using with a hierarchy of objects (an expression tree) a "pseudo" visitor pattern (pseudo, as in it does not use double dispatch) : public interface MyInterface { void ...
1
vote
2answers
768 views

Use of the Visitor pattern and possible over engineering

I am developing a small application in .NET and am thinking of using XML to save the object model. My first thought was to separate the model and the generation of XML by using the Visitor pattern. ...