Thursday, June 24, 2010

DESIGN PATTERN

QUESTION: Describe the visitor design pattern
ANSWER: 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.

QUESTION: What is a design pattern?
ANSWER: A design pattern systematically names, motivates, and explains a general design that addresses a recurring design problem.

QUESTION: Describe the visitor design pattern
ANSWER: 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.