Describe the visitor design pattern.
The visitor pattern is one of the standard patterns in the "Gang of Four" Design Patterns book. The pattern provides a powerful mechanism to invoke a type-dependent operation without explicitly testing for the type. However, using visitors is not mandatory.
It Represents an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates. The root of a class hierarchy defines an abstract method to accept a visitor. Subclasses implement this method with visitor.visit(this). The Visitor interface has visit methods for all subclasses of the baseclass in the hierarchy. (Review) (Example)
What is a design pattern?
A design pattern systematically names, motivates, and explains a general design that addresses a recurring design problem. (MVC) (J2EE)
No comments:
Post a Comment