Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

please help me write visitor design pattern

 
sam bartl
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 14
BSD Eclipse IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic