Lecture 19 Objectives
At the end of today's class you should
KNOW:
- That the visitor pattern provides a framework for traversing a
data structure, where the components of the data structure can be one of
some number of variants
- That to implement the visitor pattern, we must create a class of
function objects that know how to handle each type of variant
BE ABLE TO:
- Create a class of function objects that act as visitors
- Use the visitor objects to process each component in a data structure
Sample Exam Question:
Every variant of AbsMenuItem defines the method accept() the same way:
public boolean accept(ICount matcher){
return matcher.shouldCount(this):
}
What is the purpose of the accept() method?