visitor

How to make sure the visitor is unique

Say you have a pay-site with some online courses. And you want to make sure that one person doesn't just buy access, and then give the username and password to all his friends, so they can do the courses for free. How would you go about this? What we've thought of so far: IP tracking SMS password for each entry Max number of runs thr...

ASTVisitor in Eclipse

Hi, I am learning how to do an ASTVisitor for a project, so I started using Eclipse, which has a comprehensive API for that. I have downloaded the Packed Example Project from this website: http://www.eclipse.org/articles/article.php?file=Article-JavaCodeManipulation%5FAST/index.html But I realised that the codes do not have a main() m...

Visitor Pattern in Ruby, or just use a Block?

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 you want to encapsulate the logic into a separate "visitor" object, etc. But with Ruby, it seems like overkill because you could just use blo...

"Easiest" way to track unique visitors to a page, in real time?

I need to record in "real time" (perhaps no more than 5 minute delay?) how many unique visitors a given page on my website has had in a given time period. I seek an "easy" way to do this. Preferably the results would be available via a database query. Two things I've tried that failed (so far): Google Analytics: Does the tracking/repor...

Eclipse JDT ASTVisitor - how to tell if a field is read or written in a method?

I am writing a Eclipse ASTVisitor. How to tell if a field is read or written in a method? The idea provided was "You need to vist Assignment node. Field on the LHS is written, while fields on the RHS expression is read." After I visit the assignment and get the LHS and RHS which are both of Expression, how do I tell if the Expression c...

What's the best pattern to handle a table row datastructure?

The Facts I have the following datastructure consisting of a table and a list of attributes (simplified): class Table { List<Attribute> m_attributes; } abstract class Attribute {} class LongAttribute extends Attribute {} class StringAttribute extends Attribute {} class DateAttribute extends Attribute {} ... Now I want to do dif...

How to store state on a node for a visitor pattern?

I have an architecture that uses the visitor pattern to implement a number of passes over a tree (an AST as it happens). In one of the passes I need to associate some data with a node (nodeX) and then from some point below it get my data from a reference to the nodeX. I want to do this in a way that doesn't push the implementation of the...

Translator Pattern

In a previous job, my manager suggested use of a Translator pattern for converting data from a DataTable to objects. Basically, the Translator class had only static (i.e. class) methods so it was an aggregation of function calls. My initial approach was to implement constructors for each object that could take a DataTable row as an argum...

Question on Google Analytics

The below code is for Retrieve user Accounts on Google Analytics. My question is what is to be replaced instead of the code ga:AccountName and ga:ProfileId in the below code To find the visitors logged in on the site. /* * Retrieve 50 accounts with profile names, profile IDs, table IDs * for the authenticated user */ // Create the...

C++ visitor pattern handling templated string types?

I'm trying to use the visitor pattern to serialize the contents of objects. However one snag I'm hitting is when I'm visiting strings. My strings are of a templated type, similar to STL's basic_string. So something like: basic_string<char_type, memory_allocator, other_possible_stuff> \\ many variations possible! Since I can have very ...

Could someone in simple terms explain to me the visitor pattern's purpose with examples if possible

Hi, I'm really confused about the visitor pattern and its uses. I can't really seem to visualize the benefits of using this pattern or its purpose. If someone could explain with examples if possible that would be great. =) Thanks in advance ...

Changing a Container while using Visitor

Hi everyone, I implemented the Visitor pattern in C++ using a STL-like iterator for storing the Visitor's current position in the container. Now I would like to change the container while I iterate over it, and I'm especially interested in deleting items from the container, even the one I'm currently visiting. Now obviously this will i...

Tracking Viewing Habits of Website Visitors

Hello everyone! First time using this service for a question. I hope I am not asking something that has already been answered. I attempted to find an answer to my question with the search engine but i was unable to. My question is as follows: Using php, javascript, or anything actually, is it possible for me to track how my users are v...

When do you decide to use a visitors for your objects?

I always thought an object needs the data and the messages to act on it. When would you want a method that is extrinsic to the object? What rule of thumb do you follow to have a visitor? This is supposing that you have full control of the object graph. ...

How do i track the visitor's country and redirect them to appropriate sites?

HI I want to track the country of the visitors and then redirect them to appropriate subdomains of my site like what google does... And upto what extent i can rely on the data of the api if i should use any?.. I'm using php.. ...

need a virtual template member workaround

Hello, I need to write a program implementing the visitor design pattern. The problem is that the base visitor class is a template class. This means that BaseVisited::accept() takes a template class as a parameter and since it uses 'this' and i need 'this' to point to the correct runtime instance of the object, it also needs to be virtu...

Java abstract visitor - guarantueed to succeed? If so, why?

I was dealing with hibernate, trying to figure out the run-time class behind proxied instances by using the visitor pattern. I then came up with an AbstractVisitable approach, but I wonder if it will always produce correct results. Consider the following code: interface Visitable { public void accept(Visitor v); } interface Visito...

Apples, oranges, and pointers to the most derived c++ class

Suppose I have a bunch of fruit: class Fruit { ... }; class Apple : public Fruit { ... }; class Orange: public Fruit { ... }; And some polymorphic functions that operate on said fruit: void Eat(Fruit* f, Pesticide* p) { ... } void Eat(Apple* f, Pesticide* p) { ingest(f,p); } void Eat(Orange* f, Pesticide* p) { peel(f,p); ingest...

Visitor pattern lacking parameters

I'm sure this must be a common problem with the Visitor pattern, so thought I'd see if there is a standard solution. How can you re-code a tree traversal where the methods are built into the tree classes themselves, say class Node { void Traverse(SomeType& t) { ... } }; into code that uses a visitor. Two solutions that come to mi...

How Visitor Pattern avoid downcasting

Hello to all, can anyone show example code before and after to avoid down casting for visitor pattern code ? Thanks. ...