Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

please help me write visitor design pattern

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 14
Eclipse IDE VI Editor BSD
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic