Tree icon indicating copy to clipboard operation
Tree copied to clipboard

Semantics...

Open brunotag opened this issue 2 years ago • 1 comments

First of all, awesome work guys, very useful and helpful.

Just a comment about semantics if I may.

Your generic "Visitor" is more like an "Iterator". The "Visitor" pattern usually doesn't decide how to traverse the tree, that's what an Iterator does.

Yes, your visitors also define an output, but you might wanna separate the two concerns: turn the PreOrder and PostOrder visitors into iterators. The iterator returns the nodes one by one, and then you can pass them to a visitor that does something on them.

That way you'd decouple the traverse algorithm from whatever operation/processing the visitor wants to do.

Makes sense?

brunotag avatar Dec 12 '21 08:12 brunotag

@brunotag

Is this related to #81?

localheinz avatar Feb 24 '23 15:02 localheinz