Tuesday, July 12, 2005

Avoiding DynamicCast via patterns

How to avoid DynamicCast ? Use visitor pattern. It lets you define new operations without changing the classes of the element on which it operates.
Therefore if for example based on performance rating each employee can be given a raise the raise can be a visitor hence when the employee is given a visit by the raise, automatically all the employees get a raise appropriately. Therefore this avoids the unnecessary extension to the employee class just to add another behavior where only the client is modified the moment the criteria are changed without affecting the employee concrete class. Visitor pattern can also be known as "Object laundering"

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home