Skip to content

Semantics... #97

@brunotag

Description

@brunotag

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?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions