Trees with Generics and Visitors

Using generics and the visitor pattern, it is actually possible to define a generic tree for different objects and different operations on the tree, I have learned from the very interesting book Java Generics and Collections. This seems quite useful to me. I have added an implementation for general trees based on the binary tree implementation in that book to the Literate Programs wiki. Now what gets me thinking is that I have read someone (think it was sma) writing the visitor pattern is superfluous. Could that be meant as in ‘for certain languages, where visiting can be done very naturally’? Then this would still all make sense for Java.


About this entry