SE450
:
Inflexible Hierarchies
[38/55]
How can one add operations to compound hierarchies?
Example: AWT
Component,
Container,
etc. form hierarchy
Lots of operations:
getPreferredSize
,
repaint
Can't add new methods without modifying
Component
class
VISITOR pattern solves this problem
Each class must support one method
void accept(Visitor v)