aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes please help me write visitor design pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "please help me write visitor design pattern" Watch "please help me write visitor design pattern" New topic
Author

please help me write visitor design pattern

sam bartl
Ranch Hand

Joined: Oct 29, 2010
Posts: 44


This is a simple code where I have to use many of if conditions to determine what if block to invoke ,I want to use visitor pattern here than if blocks, Please gurus write this in visitor pattern, that will help me understand how to use visitor pattern , All the examples for visitor patterns I see in google does not tell me know how to apply in this case , please gurus help me with translate this code to use visitor pattern.
Andi Eska
Greenhorn

Joined: Jun 20, 2003
Posts: 14

The purpose of the visitor pattern is to separate an algorithm from the object structure it operates on.
It seems to me that is not the pattern you are looking for.

You need a pattern that allows you to simplify your conditional logic and that can be done using the Command_pattern
An Example how the Command Pattern can be used to handle Requests can be found on Peter Roses Blog

Another pattern in conjunction with the Command Pattern that may help you is the Chain-of-responsibility_pattern
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: please help me write visitor design pattern