strategy pattern
From: cppaddict (cppaddict_at_yahoo.com)
Date: 11/28/03
- Next message: Sean Case: "Re: Agile developement -- A Parable"
- Previous message: Hoff, Todd: "Re: Why refactoring is better"
- Next in thread: H. S. Lahman: "Re: strategy pattern"
- Reply: H. S. Lahman: "Re: strategy pattern"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 28 Nov 2003 22:52:25 GMT
I have a simple question about the strategy pattern.
I am writing a web application which will have a bread-crumb navigation
menu, which will be partly based on a url parameter, and partly based on the
state of the current bread-crumb (ie, where the user currently is within the
site).
Eg, if the user hits the page "index.html?page=browseVacancies", the
bread-crumb will look like:
Home >> Browse >> Vacancies
An example of a trail which depends on the users current state is
"index.html?page=apartmentDetails":
If the user clicks on a vacancies details link from a thumbnail picture of
an apt on the home page, the trail would be:
Home >> Browse >> Vacancies >> Unit Details for 103 Pine Road
(Note how, in the above example, the user never actually clicked on Browse
and then Vacancies)
But if a user did a quick search first, and clicked on the same details link
in the search results page, the trail should be:
Home >> Search >> Search Results >> Unit Details for 103 Pine Road
My idea was to create a NavigationContext object which would have a
different concrete strategy for each url page variable, and those strategies
would call a method to return the appropriate bread crumb. However, that
still leaves open the question of how to handle the second case, where the
selection of the bread crumb trail depends on the current trail, possibly in
some complex way (more complex than the apartmentDetails example above).
In the above "apartmentDetails" example, should the logic which branches on
the current state be put into the concrete strategy for the
"apartmentDetails" event? Moreover, if there were five different results
(based on current page state) instead of two, should the "apartmentDetails"
implement its own strategy pattern, based on page state, resulting in a
nested strategy pattern?
Or is there a better way to approach this?
Thanks for any ideas,
cpp
- Next message: Sean Case: "Re: Agile developement -- A Parable"
- Previous message: Hoff, Todd: "Re: Why refactoring is better"
- Next in thread: H. S. Lahman: "Re: strategy pattern"
- Reply: H. S. Lahman: "Re: strategy pattern"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]