Live data from Hacker News

Grim C++ Tales from the Crypt: The Visitor Pattern (2017)

cppcrypt.tumblr.com

1–10 of 64 posts

Re: Grim C++ Tales from the Crypt: The Visitor Pattern (2017)

#3
The thing that annoys me most about this pattern is that people always miss the "there needs to be lots of things you want to perform on those thingies".

And so we end up with a huge pile of visitor code, and there is one or maybe two actual visitors.

When it would have been far easier to read and modify if it was just coded out normally.

Re: Grim C++ Tales from the Crypt: The Visitor Pattern (2017)

#4
If you're like me and couldn't get past the first few slides because it's a terrible reading experience, go to the archive, which shows the whole thing in thumbnails. It makes it little better, even though the thumbnails are in reverse:

https://cppcrypt.tumblr.com/archive

Re: Grim C++ Tales from the Crypt: The Visitor Pattern (2017)

#5

If you're like me and couldn't get past the first few slides because it's a terrible reading experience, go to the archive, which shows the whole thing in thumbnails. It makes it little better, even though the thumbnails are in reverse: https://cppcrypt.tumblr.com/archive

This would definitely be better as a blog post than a dog post.

Re: Grim C++ Tales from the Crypt: The Visitor Pattern (2017)

#6

If you're like me and couldn't get past the first few slides because it's a terrible reading experience, go to the archive, which shows the whole thing in thumbnails. It makes it little better, even though the thumbnails are in reverse: https://cppcrypt.tumblr.com/archive

This would definitely be better as a blog post than a dog post.

What is a dog post?

Re: Grim C++ Tales from the Crypt: The Visitor Pattern (2017)

#7
post #6

Earlier quoted context omitted.

This would definitely be better as a blog post than a dog post.

What is a dog post?

It's when you cut your blog post into tweet-sized blocks and post each tweet in a separate jpeg with a cartoon dog.

Re: Grim C++ Tales from the Crypt: The Visitor Pattern (2017)

#8
post #3

The thing that annoys me most about this pattern is that people always miss the "there needs to be lots of things you want to perform on those thingies". And so we end up with a huge pile of visitor code, and there is one or maybe two actual visitors. When it would have been far easier to read and modify if it was just coded out normally.

IMHO, the most important condition is the need to do different stuff on different (small) subsets of classes, typically combined with a (non-trivial) tree traversal. Otherwise, its more straightforward to add regular virtual methods.

Re: Grim C++ Tales from the Crypt: The Visitor Pattern (2017)

#9
post #3

The thing that annoys me most about this pattern is that people always miss the "there needs to be lots of things you want to perform on those thingies". And so we end up with a huge pile of visitor code, and there is one or maybe two actual visitors. When it would have been far easier to read and modify if it was just coded out normally.

I’ve never considered this, but I think it’s a fair assessment! It’s particularly striking when you see a compiler with multiple visitors that are refactored into one or two visitors to reduce the number of traversals. I think I understand the cause, it’s easier to start with a visitor pattern than refactoring into a visitor pattern.

Nevertheless, for many problems, like compiler construction, I’ve never seen a pattern that matched the utility of the visitor (even outside of imperative and object-oriented patterns)

Post reply on HN