• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Difference between strategy and template method patterns

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

This is my first post on Javaranch and I have just started to implement patterns to an application. My Application is similar to EBay.

Here I am not sure if I have to use template pattern or strategy pattern to process search Listing.

If I use template than I have a template method which does basic search.

This method is defined in Manager class , Administrator class and User class.
So every one have different kind of search options inside that template method, example admin will search for accounts, where as user will search for items.


If I use Strategy than I was thinking like i will write a basic search method where search is based on two types generic search and advanced search based on the entered item.

I am not sure as a designer which idea i should consider to make my search works similar to ebay search.

I was also thinking to use strategy pattern for the services( listing, selling, buying,bidding)

Can i combine template search and strategy services? I wanted to know if i following the right approach.


thanks in advance
Nandita
 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Nandita

You have to take decision yourself. No one can guide you with few lines of information. And please understand patterns are standard solution to the standard problem/situation (in design), you can apply any patterns to any problem/situation, But you have to see weather is this patterns is really for the design problem/situation. And you can merge any patterns, if it make sense to you. For example i used strategy patterns at three different places, but none of it is pure strategy. I changed it bit, but it's OK as it is making sense to me.

Even you can code in one class and still your search may works similar to ebay search, if you want.

I'll say go step by step. And evaluate (which patterns should be used) by yourself.

Regards,
Nachiket
[ November 04, 2008: Message edited by: Nachiket Patel ]
 
Nandita Yerramareddy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Nachiket! for clearing my novice doubts . I guess now i have some clear idea on using patterns in an application.
reply
    Bookmark Topic Watch Topic
  • New Topic