2 ms·
> do they simplify programming for beginners? I don’t think they do. > What are they for, really? To reason about code. To explain to others what the code do
by Const-me 9y ago
> do they simplify programming for beginners?
I don’t think they do.
> What are they for, really?
To reason about code. To explain to others what the code does. Also to document code.
> 'visitor pattern' -- does any pattern intro tell people that this exists only because Java and C++ have no multiple dispatch?
Visitors are sometimes useful when you do multiple different filter/search/transform operations on the same tree data structure, especially if the tree contain heterogeneous elements i.e. walking is not trivial. Visitor pattern allows you to write tree-walking code once, and reuse it with different operations = different concrete visitors.