2007-09-11

再谈Iterator vs Visitor

关键字: 模式
Iterator和Vistor的描述见http://www.javaeye.com/topic/21293。 啥时候用Iterator?啥时候用Vistor?从我的角度看来Vistor是为了解决Iterator的问题而出现的。Iterator有啥问题呢?设想这么一套类体系:类很多,几百个,类继承层次和关系也很多,这个时候,用Iterator,如下:     while ( (node = iter.next()) != null){ ..... node.method1(); .....     } OK,处理方法是写在 ...
firmgoal
搜索本博客
最近加入圈子
最新评论