Understanding The Visitor Design Pattern
Video Statistics and Information
Channel: The Simple Engineer
Views: 31,775
Rating: 4.9269776 out of 5
Keywords: Visitor, Visitor Design Pattern, Pattern, Design Patterns, Design Pattern Tutorial, Design Pattern Video Tutorial, visitor pattern, design pattern, visitor design pattern c++
Id: TeZqKnC2gvA
Channel Id: undefined
Length: 32min 7sec (1927 seconds)
Published: Sat Jan 19 2019
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
I like this video and the channel but I have to quibble if you don't mind. Is it really true the visitor pattern was made to "solve" double dispatch?
I think you get a lot right in the video but I think you get a detail wrong that hampers understanding. I feel like you're saying the reason for visitor is double-dispatch but I don't agree - i think that's an implementation. The reason for a visitor pattern is, as you say in the video, to perform an new operation on a class when you can't modify that class (b/c you don't own it, b/c it breaks the interface, and son o.).
If you never even mentioned double-dispatch, your viewers would have a much more succinct concept of visitor. You could then layer more concepts on top. There is some real sense in which you could say that python classes make almost universal use of visitor to implement its methods. But you wouldn't find a conversation about double dispatch there.
You're right, the main point tailors to APIs and such you cannot modify or don't want to modify. Maybe I'm off a bit by saying it solves the lack of double dispatch in OOP, however, I do believe it's a way to resolve the lack of double dispatch being inherently available within the language. It does bring to the table some dynamic runtime polymorphism between to abstract types.