visitor-pattern Questions

4

Solved

Suppose I have a suite of classes that accept a visitor (visitor-pattern), but due to the nature of those classes or a particular visitor, performing working on them will likely be capable of throw...
Centaur asked 7/11, 2013 at 16:57

8

A depth first search seem able to perform similar functions as the visitor design pattern. A visitor allows you to define some data structures and add operations on those structures (in the form of...
Erechtheum asked 9/6, 2011 at 20:52

5

Solved

There is no direct support for variant types (aka tagged unions, discriminated unions) in C#. However one can go with a visitor pattern that enables discrimination via double-dispatching and guaran...
Washcloth asked 14/10, 2013 at 1:40

1

I have to write a visitor pattern to navigate the AST. Can anyone tell me more how would I start writing it? As far as I understand, each Node in AST would have visit() method (?) that would someho...
Theory asked 23/4, 2013 at 9:23

3

Solved

I've seen a couple of examples that demonstrate the visitor pattern. In all of them, each derived visited element implements what's usually called the Accept() method. In a hierarchy of colors, t...
Cinquefoil asked 19/6, 2013 at 12:13

2

Solved

I have a custom class, but I want to be able to pass it to Arel and let it resolve its queryable part. module Custom class Item attr_accessor :name def initialize(name) self.name = name end...
Proofread asked 15/6, 2011 at 13:57

1

Solved

I have to write a piece of code that loads a remote web page, search for the links, visit those pages and gather some info from certain tags... How would you do this? Is the visitor pattern of any...
Gynandrous asked 23/5, 2013 at 14:53

2

Solved

I am stuck with a code duplication issue, regarding the visitor pattern for a tree. The current situation is as follows: I have a tree, consisting of two different node classes, i.e. leafs and non-...
Jueta asked 13/5, 2013 at 13:12

3

I'm having trouble extending an application. It is an attendance record system. Currently each employee records attendance by a card that has a QR code. Now they want to add fingerprint recognition...
Yovonnda asked 25/4, 2013 at 15:56

3

Solved

I'm wondering whether there is a good design pattern or idiom to realize the following: You have an existing class that provides only a visitor interface, as follows class Visitor { public: vi...
Fulmination asked 1/4, 2011 at 0:11

3

Solved

Let's imagine I have a collection of nodes that I use for my Renderer class later on. Then I have a Visitor class that can visit node or whole collection. It's simple because my collection of nodes...
Crimea asked 11/2, 2009 at 21:20

2

Solved

NodeVisitor traverses the AST depth-first and visits each node only once, on enter. Therefore it's problematic to do something serious with it. Is it possible to change its default behavior?
Tompion asked 4/4, 2011 at 1:7

2

Solved

I have a expression made by composite design pattern: interface TreeExpression{ void accept(Visitor visitor); } abstract class Operator{ TreeExpression childA; TreeExpression childB; Operato...
Creamcolored asked 22/1, 2013 at 23:11

2

Solved

Is there any significant benefit to using either technique? In case there are variations, the Visitor Pattern I mean is this: http://en.wikipedia.org/wiki/Visitor_pattern And below is an example o...
Leund asked 7/12, 2012 at 22:40

1

I have a graph and a set of very simple visitors that do some calculations on vertices/edges of the graph such as getting the total weight of edges and pretty-printing the graph. I would like to g...
Agustinaah asked 26/7, 2012 at 10:23

1

Solved

Is there a way to implement visitor design pattern without cyclic dependency? What I mean is that the visitor need an object to visit. and the visited object needs a visitor to accept. In the...
Leuco asked 1/10, 2012 at 11:38

1

Solved

I'm trying to use the visitor pattern to perform operations for the AST of my compiler but I can't seem to figure out an implementation that will work properly. AST classes excerpt: class AstNode...
Airily asked 13/7, 2012 at 5:38

1

Solved

Consider the following hierarchy: class Base { virtual void Method() = 0; virtual void Accept(Visitor *iVisitor) = 0; }; class Derived1: public Base { virtual void Method(){//impl} virtual voi...
Juliettejulina asked 6/7, 2012 at 15:59

2

Solved

I have an implementation of a State Pattern where each state handles events it gets from a event queue. Base State class therefore has a pure virtual method void handleEvent(const Event*). Events i...
Marler asked 23/5, 2012 at 11:13

1

Solved

I am trying to implement the Visitor Pattern for an object structure which has methods with different return types (string, signed int, unsigned int, etc). Now, in the object hierarchy I have add...
Avictor asked 15/4, 2012 at 18:17

1

Solved

As far as I understand, visitor pattern is often used to add methods to some hierarchy structure. But I still don't get it: see the example where I try to highlight left subtree: Javascript tree...
Enwreathe asked 22/3, 2012 at 22:20

2

Solved

Hey there, I have read the few posts here on when/how to use the visitor pattern, and some articles/chapters on it, and it makes sense if you are traversing an AST and it is highly structured, and ...
Potboy asked 5/10, 2009 at 6:10

5

Solved

What is the difference between Double Dispatch and the Visitor Pattern?
Emerick asked 22/3, 2012 at 7:35

2

Solved

I've been looking at the best way to implement the Visitor design pattern in Objective-C. Since the language doesn't support method overloading, a 'traditional' implementation such as one might fin...
Predict asked 20/2, 2012 at 18:2

1

Solved

In this question it is said I can use visitor pattern instead of a bunch of instanceofs. Jmg said "If you are not free to change A, B, and C, you could apply the visitor pattern to achieve the same...
Dilution asked 20/12, 2011 at 6:14

© 2022 - 2024 — McMap. All rights reserved.